• Fri. Sep 24th, 2021

Find out which SQL Agent Jobs that are currently running

ByGary Cowan

Dec 4, 2018
SQL Server Agent Jobs

Find out which SQL Agent Jobs that are currently running

If you ever want to find out which SQL Server Agent jobs that are currently running on your server without using Management Studio, just run the code below.

j.name AS job_name,
ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
FROM msdb.dbo.sysjobactivity ja
LEFT JOIN msdb.dbo.sysjobhistory jh ON ja.job_history_id = jh.instance_id
JOIN msdb.dbo.sysjobs j ON ja.job_id = j.job_id
JOIN msdb.dbo.sysjobsteps js
ON ja.job_id = js.job_id
AND ISNULL(ja.last_executed_step_id,0)+1 = js.step_id
ja.session_id = (
SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY agent_start_date DESC
AND start_execution_date is not null
AND stop_execution_date is null
order by 2 desc

Gary Cowan

I have been working with SQL Server for 20 years and have administrated and developed software solutions with SQL Server from SQL Server 6.5 through to SQ Server 2019. I have MCTS, MCP, MCDBA and MCITP Qualifications in SQL Server.

Leave a Reply

Your email address will not be published. Required fields are marked *