Job to run more than one job in order

  • I have a number of jobs written which I would like to keep that way as sometimes I need to run them manually. However most of the time I want to have a job which executes them all in a certain order. However if I set these job going using EXEC [msdb]..sp_Start_Job it sees starting the job as being successful so fires the next job immediately. However the next job relies on the previous job being completed so my data warehouse build falls down. Any ideas without creating another job with all the steps from my 6 jobs in it ?

  • The initiating job is going to have to start the first job, then wait until that job finishes, then start the next job, etc..

    You could set up full messages using brokering, etc., but to keep it simple, I'd just:

    have each job delay (n) minutes (WAITFOR DELAY ...), check for the job having completed, if not, wait again, etc., until each job finishes.

    You can use msdb.dbo.sysjobhistory, step_id 0 written for the job, to see when a job finishes. Naturally you'd need to check date and time to make sure it was the most recent completion.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Removed, duplicate.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Removed, duplicate post.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply