Monday, March 19, 2012

How Can I make one Job dependant on the sucess of another?

Hi

I need to create a SQL Server job that is dependant on the sucess of another. I'm not able to put both steps in the same job becuase they need to run at different times of the day.

If my first job over runs or hangs for what ever reason I do not want my second job that starts an hour later to start until the first job finishes OR if my backup hangs or over runs I do not want my first job to start.

You can add multiple schedules to a SQL job but I can't see away of assigning individual stepes to the schedules and don't even know if this would do what I need.

How do other people contorl dpendancies between jobs that need to execute at different times of the day and therefore can't exist int he same job.

Thanks for your help

Marcus

In the first job, you could add a second step that upon competition of the first step enables the second job, and then in that second job add a step disables the job upon successful completition.|||Even on that job step you can state to stop on failure, where the next job setps will not be executed.|||With the OP's requirement that the subsequent 'job' or 'steps' run on a different schedule, it seems that 'stop on failure'/'continue on success' would not really be a solution.|||Or else you can program the same using SP_START_JOB for that specified step name, books online is best resource to check for syntax and examples.|||

I tried this solution but unfortunately it doesn't work. The master job that issues the start job for ALL the others works fine.

the problem is it starts the step, thus starting the job and immediately goes on to the next one. Basically starting them all at once

Does anyone have any other ideas?

I tried the SSIS task that starts jobs but this has the same behaviour.

I'm really suprised that microsoft hasn't figured out that someome may want to schedule jobs that have dependacies.

cheers

Marcus

No comments:

Post a Comment