SQL SERVER – Running SQL Agent Job After Completing Another Job

A really very interesting situation I faced with my client while working on Comprehensive Database Performance Health Check. They wanted to run SQL Server Agent Job After Completing Another Job. Well, it is possible and very easy to do.

There is no need to guess the time of the first job to complete or also there is no need to write complicated jobs to look for job status or job completion history. It is very easy to start another job when one job completes.

When you are creating various steps for the Job, create the last step with the help of the system stored procedure sp_start_job.

Start Agent Job

USE msdb ;  
EXEC dbo.sp_start_job N'Name of Job' ;  

When the last step runs with the above SP, it will automatically run the next job. The solution is very simple but I have not seen many using this in the industry.

Here are my few recent videos and I would like to know what is your feedback about them. Do not forget to subscribe SQL in Sixty Seconds series.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Exit mobile version