Sql-server – How to launch SQL Server Agent job on completion of another one

maintenancesql serversql-server-2012sql-server-agent

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

Best Answer

Use sp_start_job.

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