How to invoke a SQL job from another Job present on a different instance | SansSQL

Wednesday, September 18, 2013

How to invoke a SQL job from another Job present on a different instance

For invoking an SQL Server Job from another Job which is present on a different instance, we have different ways like
  1. Create a Linked server and use msdb..sp_start_job to start the job
  2. Using xp_cmdshell
  3. Using SQLCMD Operating system command
In most of the SQL Server instances the xp_cmdshell will be disable due to security reasons and creating linked server is time consuming.

So, the most easy approach would be to use the SQLCMD Operating system command.
Create a new step in the job with the type "Operating System (CmdExec)" and use the below command
SQLCMD -S <Server Name> -E -Q "EXEC msdb..sp_start_job <Job Name>"

No comments:

Post a Comment

Ads