SELECT
j.name AS JobName,
ja.start_execution_date,
ja.stop_execution_date,
ja.run_requested_date,
CASE
WHEN ja.start_execution_date IS NOT NULL
AND ja.stop_execution_date IS NULL
THEN 'Running'
ELSE 'Not Running'
END AS JobStatus
FROM msdb.dbo.sysjobs j
JOIN msdb.dbo.sysjobactivity ja
ON j.job_id = ja.job_id
WHERE ja.session_id = (
SELECT MAX(session_id)
FROM msdb.dbo.sysjobactivity
)
AND ja.start_execution_date IS NOT NULL
AND ja.stop_execution_date IS NULL;
--EXEC msdb.dbo.sp_stop_job
-- @job_name = 'YourJobName';
Sign up here with your email
ConversionConversion EmoticonEmoticon