Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have one job on SQL server Job Agent that has 3 steps. I want to the job to run starting with step one. After step one is complete and only when it completes I want step 2 to start running and so for step 3

share

migration rejected from stackoverflow.com Jul 3 '13 at 16:51

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as unclear what you're asking by Mark Storey-Smith, Nick Chammas, Paul White, swasheck, dezso Jul 3 '13 at 16:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
You can separate queries with GO as a batch terminator in SSMS, not familiar with Job Agent. –  Goat CO Jul 2 '13 at 18:27
1  
So from the comments below, it's unclear what you actually want to do. Do you want to run the job steps in order (as will happen by default), or do you want to be able to also call step 2 on its own and ONLY run step 2, or do you want step 2 to start immediately after step 1 has started? And if you want step 2 to wait for step 1 to finish, well it all depends on what the steps are doing. If step 1 calls sp_start_job or invokes some service broker or other asynchronous process, you can't really make step 2 wait for that... –  Aaron Bertrand Jul 2 '13 at 22:32
    
There is an option in the steps on what to do on 'success' or 'failure'. For eg: You can set step1 to continue on success or stop on failure (i.e. do not go to step2). If this what you were looking for? –  StanleyJohns Jul 3 '13 at 2:12
comments disabled on deleted / locked posts

1 Answer 1

The default in SQL Server Agent jobs is to run the steps sequentially. Step two will start only after Step one has completed etc. Although under the advanced settings you can change it to go from Step 1 to Step 3 and skip Step 2. In fact the only way I know of to avoid this is to create three separate jobs and have them all run at the same time.

EDIT: Here is an example of what the steps look like by default. Note that on successful completion each job goes to the next step.

enter image description here

And here is an example where the default has changed. Note that step one goes directly to step three and step two will never be run.

enter image description here

Edit2:

I should probably note that if the task the step is performing is asynchronous then the step will "end" and start the next step after launching the asynchronous task without waiting for that task to complete. Examples would be using a service broker or starting another job. In those cases I know of no way to force the agent to wait until the asynchronous task has been completed before starting the next step.

share
1  
So, you're saying that what he wants is what should be happening? –  thursdaysgeek Jul 2 '13 at 23:25
    
@thursdaysgeek Pretty much yes. I've added a couple of pictures to show how a step can be missed and the default way it goes. –  Kenneth Fisher Jul 3 '13 at 1:45
    
Yes, the questioner basically described the default behavior. Not sure why it's on hold for clarity unless we're mind reading and suspect the user meant to ask something else –  Paul Jul 4 '13 at 14:04
add comment