HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to run sql agent jobs in a sequence order.with T-sql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
ordersqlwithagentsequencejobshowrun

Problem

My requirement is to run the SQL Agent jobs (EX: job1 to job10) with T-sql in a sequence order. That means job2 starts automatically when job1 completes. This process should continue until job10 completes.

Thank you.

Solution

Have the last step of job 1 be to fire job 2, use this code:

EXEC dbo.sp_start_job N'MyJob 2'


Then, the last step of job 2 be to fire job 3, so on and so forth.

Code Snippets

EXEC dbo.sp_start_job N'MyJob 2'

Context

StackExchange Database Administrators Q#78763, answer score: 2

Revisions (0)

No revisions yet.