Check for running Job – MSSQL

SQL To check if a job is running before trying to kick it off from a step in another job:

—————————————————

USE msdb ;
GO
IF NOT EXISTS (
SELECT sj.name, sja.*
FROM msdb.dbo.sysjobactivity AS sja
INNER JOIN msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id
WHERE sja.start_execution_date IS NOT NULL
  AND sja.start_execution_date >= DATEADD(day,-1,getdate())
  AND sja.stop_execution_date IS NULL
AND sj.name='<JobName>’
)
EXEC msdb.dbo.sp_start_job N'<Job Name>’
ELSE
PRINT ‘Job already running!!’

————————————————–