1

I have two SQL Server machines:

  1. SqlServer-1
  2. SqlServer-2

I have a job created on SqlServer-1 named RunExeFile.

SqlServer-2 can access SqlServer-1 through a linked server.

Can I start the job RunExeFile from a stored procedure on SqlServer-2 ?

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
Ali
  • 91
  • 1
  • 8

1 Answers1

2

Yes, you can.

You can run this in your stored procedure on SqlServer-2 against linked Server LinkedServer1:

EXEC LinkedServer1.msdb.dbo.sp_start_job @job_name = N'RunExeFile';

You need to configure RPC and ensure the calling security context is set:

enter image description here

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • Server 'SQLServer-1' is not configured for RPC – Ali Dec 22 '20 at 23:52
  • 1
    so configure it for RPC : https://stackoverflow.com/questions/50907968/server-is-not-configured-for-rpc – Mitch Wheat Dec 22 '20 at 23:52
  • Oh yes I did that, but now I'm getting another error The EXECUTE permission was denied on the object 'sp_start_job', database 'msdb', schema 'dbo'. – Ali Dec 22 '20 at 23:56
  • 1
    then that's another question.......It's saying you need to configure the user that the linked server call runs as. That's a different problem. – Mitch Wheat Dec 22 '20 at 23:56