Having a job wait for another job | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Having a job wait for another job

I am currently building an SQL Server job. One of the steps of the job is to run sp_start_job to call another job that already exists on the server. However, I’m finding that the server immediately goes on to the next step right after calling the job. How can I get the job to wait for the step to complete before going on to the next job? Zev Steinhardt
Go to Ent Manager>Management>SQL Server Agent>Jobs.
Right-click the job then go to Properties.
From the ‘Steps’ tab, edit the step by clicking on ‘Edit…’ button. Another window should appear, click on the ‘Advanced’ tab and specify the ‘On success action:’ as ‘Goto next step’ or ‘Goto step: (step ID here)’. Jon M
Jon, Thanks for replying. Unfortuantely, it’s not that simple. To start the sub-job, I’m using sp_start_job. So, as soon as it starts the sub-job it goes on to the next step. Is there a way to have it start the sub-job, wait until it’s finished and then proceed? Zev Steinhardt
You can use sp_start_job to start a specific step name. Check BOL for more information. 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.
]]>