SQL Server Performance Forum – Threads Archive
Job call another job
Apologies if this is a silly question, but how do you start a job using sql? I have a job (Job A) that does my backups, and when it completes i want to add another step to start a second job (Job B). I dont want to add the code from Job B to Job A as they perform 2 different functions. From looking in BOL, i know that i could raise an event and run the second job when the event occurs, but there has to be an easier way! Thanks,Ben ‘I reject your reality and substitute my own’ – Adam Savage
sp_start_job
Instructs SQL Server Agent to execute a job immediately. Syntax
sp_start_job [@job_name =] ‘job_name’ | [@job_id =] job_id
[,[@error_flag =] error_flag]
[,[@server_name =] ‘server_name’]
[,[@step_name =] ‘step_name’]
[,[@output_flag =] output_flag]
… make sure you specify SERVERNAME exactly otherwise it will tend to run as a local server. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS†with no rights for the sake of knowledge sharing.
Thanks a lot guys! ‘I reject your reality and substitute my own’ – Adam Savage
]]>