ms sql how to see active job current run time

Solutions on MaxInterview for ms sql how to see active job current run time by the best coders in the world

showing results for - "ms sql how to see active job current run time"
Isabel
04 Jan 2017
1SELECT
2    ja.job_id,
3    j.name AS job_name,
4    ja.start_execution_date,      
5    ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
6    Js.step_name
7FROM msdb.dbo.sysjobactivity ja 
8LEFT JOIN msdb.dbo.sysjobhistory jh 
9    ON ja.job_history_id = jh.instance_id
10JOIN msdb.dbo.sysjobs j 
11ON ja.job_id = j.job_id
12JOIN msdb.dbo.sysjobsteps js
13    ON ja.job_id = js.job_id
14    AND ISNULL(ja.last_executed_step_id,0)+1 = js.step_id
15WHERE ja.session_id = (SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY agent_start_date DESC)
16AND start_execution_date is not null
17AND stop_execution_date is null;
18