SQL Agent Job

  • I am looking to see if there is a better way that SQL Agent job to finish job1 and then kick of the job2 after it finishes the Job1, I have 10 hr maintenance window, before the  next business day begins. So I have to make sure the two SQL Agent jobs has to finish. I know the integrity check db as job 1 which would take approx. 3 – 5 hrs and Job2 i.e.  index rebuild will take 3 – 4 hrs. I am looking to find a way that rather than waiting for the Job1 to finish and manually kick of the Job2, is there a way I can automate, so that Job2 should kick off after the Job1 finishes. There two jobs are two different jobs.

  • Admingod - Thursday, March 28, 2019 3:59 PM

    I am looking to see if there is a better way that SQL Agent job to finish job1 and then kick of the job2 after it finishes the Job1, I have 10 hr maintenance window, before the  next business day begins. So I have to make sure the two SQL Agent jobs has to finish. I know the integrity check db as job 1 which would take approx. 3 – 5 hrs and Job2 i.e.  index rebuild will take 3 – 4 hrs. I am looking to find a way that rather than waiting for the Job1 to finish and manually kick of the Job2, is there a way I can automate, so that Job2 should kick off after the Job1 finishes. There two jobs are two different jobs.

    You might want to play around with how job steps work. You can have each process in one job on two job steps.
    Step one the integrity check and then select what to do on the success or failure of the job step. You can go to the next step (or any other steps) upon failure or success. So you can go to step two on the success or failure of the first job step.
    If you want to do something different if step one fails, it can go to a third step on failure. You can go to the index rebuild after doing whatever you want in the third step you went to on failure. You can also just go to step two on success and just skip the third step. Or if step one fails and you just want to move to the next step, you can do that as well. You can do a lot by playing around with the steps and what happens upon success or failure of the step.
    Another option would be to just add a second step to the first job and have that execute the other job using sp_start_job in the second job step.

    Sue

Viewing 2 posts - 1 through 1 (of 1 total)

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