Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

An SQL Server Agent job (SSA) have to be executed after a few other SSA jobs.

Is there any way to start SSA jobs on completion (or success, or failure) of another one?

Currently, I do this on schedule adding the delay for the duration of previous jobs. This is uncomfortable for many reasons:

  • the real execution time of preceding job can exceed the usual time and and the follow-up job will start without required completion;
  • if to include the follow-up processing as job steps then I need to duplicate them over a few jobs

SQL Server 2012 R2 on Windows Server 2008 R2

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use sp_start_job.

Put that command into a job step as needed. No need to worry about the duration of previous jobs.

share|improve this answer
    
But, this is what I mentioned in "if to include the follow-up processing as job steps then I need to duplicate them over a few jobs". For example, I need to copy local backups created by 2 SQL Server Agent job (running the weekly and daily maintenance plans, resp.). Then I need to create the same follow-up steps (which are quite big and numerous) and I need to synchronize the possible changes in the dupes not only inside the different jobs of the same server but, also, between dozens different regional servers! –  Fulproof Oct 31 '13 at 5:10
    
What @SQLRockstar meant was that you create a job with all your follow-up steps and add a new step in your existing jobs using sp_start_job to start it. –  Twinkles Oct 31 '13 at 7:50
    
@Fulproof You could choose to look at creating master jobs, too. Also, jobs can be scripted, so if you had to make a change to many servers you could get that done using a script, too. –  SQLRockstar Oct 31 '13 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.