SQL Agent Job: Determine how long it has been running

后端 未结 3 2131
萌比男神i
萌比男神i 2021-02-14 14:14

The Scenario

There are certain SQL Agent Jobs that are scheduled to run every few minutes throughout the day.

There are legitimate times when it

3条回答
  •  失恋的感觉
    2021-02-14 14:57

    /**** FOR CURRENTLY RUNNING JOBS ****/
    SELECT j.name AS Job_Name,DATEDIFF(ss,a.start_execution_date ,GETDATE ())   
    FROM msdb.dbo.sysjobactivity a INNER JOIN msdb.dbo.sysjobs j 
    ON a.job_id =j.job_id
    WHERE CONVERT(DATE,a.start_execution_date )=CONVERT(DATE,GETDATE ())
    AND a.stop_execution_date IS NULL
    
    
    /*This code will give u the Name of currently running jobs and for how much time it is running & after that u can add filters to it as u wish*/
    /*Thanks in advance*/
    

提交回复
热议问题