Skip to content

Instantly share code, notes, and snippets.

@kmoormann
Created November 1, 2012 20:50
Show Gist options
  • Save kmoormann/3996459 to your computer and use it in GitHub Desktop.
Save kmoormann/3996459 to your computer and use it in GitHub Desktop.
Check if SSIS Job is Running
DECLARE @JOB_NAME SYSNAME = N'Daily update of indexes & statistics';
IF NOT EXISTS(
select 1
from msdb.dbo.sysjobs_view job
inner join msdb.dbo.sysjobactivity activity on job.job_id = activity.job_id
where
activity.run_Requested_date is not null
and activity.stop_execution_date is null
and job.name = @JOB_NAME
)
BEGIN
PRINT 'Starting job ''' + @JOB_NAME + '''';
EXEC msdb.dbo.sp_start_job @JOB_NAME;
END
ELSE
BEGIN
PRINT 'Job ''' + @JOB_NAME + ''' is already started ';
END
@kmoormann
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment