How to implement SQL Server Job that waits to another job finish?

Posted by Fernando on Stack Overflow See other posts from Stack Overflow or by Fernando
Published on 2010-02-01T11:24:32Z Indexed on 2010/04/20 7:03 UTC
Read the original article Hit count: 263

Hi,

I'm looking a way to implement a precedence step on SQL Server Agent that will verify is a specific job is running. If so, the step will entry in a "wait" state until first job finish with success.

To clarify, this will be the cenario:

Job Name: 'My Job'

Job to be checked: 'Validate tables'

Steps of 'My job':

Step 1: Check if 'Validate tables' is running Step 2: Do something else

On Step 1, need to use some T-SQL like this: exec msdb.dbo.sp_help_job @job_name='Validade tables',@job_aspect ='JOB'

If the current_execution_status is equal to 1, then will wait (will not run the step 2)

I'm not an expert on SQL Server Agent, so I need some help on this.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about sql-server-agent

Related posts about delayed-job