Start a SQL Agent Job in SQL

How do you start a SQL Agent job in SQL? I recently found myself wanting to be able to do this and it turns out it’s really easy:

exec msdb.dbo.sp_start_job 'Check Integrity'

It returns as soon as the job has started, without waiting until the job has finished. You could use it to run a job from a script or a stored procedure. But the way I use it is in the last step of a job in order to run jobs in sequence without having to guess in the schedules how to time them. No wasted time and no danger of the second job running before the first one has finished.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s