I'm trying to figure out if a particular SQL Scheduled job is currently running on SQL Server 12.0.5000.0.
I was thinking I could do code similar to the following:
declare @jobid UNIQUEIDENTIFIER
SELECT @jobid = job_id
FROM
msdb.dbo.sysjobs
where name = 'My Job Name'
select * FROM msdb.dbo.sysjobactivity where job_id=@jobid
and start_execution_date is not null and stop_execution_date is null
It does find my running job. Also if I stop the job, I see the stop_execution_date gets populated. However, I have a bunch of other entries in the sysjobactivity that have a populated start_execution_date and a NULL stop_execution_date. Do you know what these could be?
Thanks