Sql Server agent job

  • Hi,

    How can i make kql server 2005 agent jobs interdependent,

    So that on successful execution of job1 the job 2 should get start on its own, and if job 1 was failed then job 2 should not execute.

  • Hmm you can add a condition on to the second job that checks for the first job, the information about the jobs can be obtained from sysjobhistory table on msdb, and check for runstatus flag for the job

    Hope this helps

  • Thanks but main probelem is how will job 2 come to know that job 1 is completed, it cannot be scheduled because if job 1 take more than normal time to execute then job 2 will probably not run..

    I want whenever job1 is completed job 2 should start on its own.

  • There are 2 ways to do this, make 2 job into one job, Job one must be step 1 of the new job and job 2 should be step of the new job, this is the easy way.

    The other option is, if you are using 2005, there is a retry attempt and time for that, you can write a code that checks job 1 and then if it fails then retry after a minute, else alert you if Job 1 fails

    Hope this helps 🙂

  • You can place sp_start_job to start job 2 as the last step in job 1.

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

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