Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp_start_job question 2

Status
Not open for further replies.

jonwolds

Programmer
Aug 6, 2002
194
GB
I have a table listing the job_id and the order the jobs are to be run. I am looping through the table running sp_start_job for each job_id in the table.

The problem is that I need to wait until the current job finishes before sp_start_job starts the next one.

Is there a way to do this with out continously monitoring the job status?

Thanks
Jon
 
Have thought of a better idea. This would be to create a new job which calls all the other jobs as steps.

Anything better please let me know.

Jon
 
Star for solving your own problem.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
I don't deserve the star. It doesn't work. The job steps in the new job are 'exec sp_start_job ..etc'. Once the job has started it moves onto the next job step. This means that multiple steps can run at the same time.

Any thoughts anyone?
 
I think your problem is that you have sp_start_job as the steps. It would consider starting the job as success of the step.

Have you tried putting what is actually in the jobs as the steps in a amultiple step process? Then the completion of the task would be the indicator of success of the step which would cause it to move onto the next step.

Questions about posting. See faq183-874
 
Interesting, sounds like it's unable to distinguish between the successful completion of a job vs a step within a job. Is it a national disaster to put all the steps of all the jobs into one job?
Alternatively, you could just schedule each job individually giving each sufficient time to finish.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Thanks for your thoughts. Due to the volume of jobs and job steps I think I'll run the first job then periodically check (Using WAITFOR) the status until it has finished then kick off the next job and so on.

Pretty ugly method though.
 
Ok then do it this way. Make the last step of job 1 be to start job 2 and so on.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top