SQL Server Performance Forum – Threads Archive
Having a job wait for another jobI 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
This posting is provided â€œAS ISâ€ with no rights for the sake of knowledge sharing.