SQL Server – SQL Server Agent Job History

The other day, I was troubleshooting a database slowness issue when the lead application developer asks me whether or not there are any SQL Jobs running during that time. The T-SQL​​ script below helped me to retrieve that info. This T-SQL script will check the SQL Agent Job history.

 

 

SELECT

​​ j.name​​ AS​​ 'JobName',

​​ run_date,

​​ run_time,

​​ msdb.dbo.agent_datetime(run_date,​​ run_time)​​ AS​​ 'RunDateTime'

FROM​​ msdb.dbo.sysjobs j​​ 

INNER​​ JOIN​​ msdb.dbo.sysjobhistory h​​ 

​​ ON​​ j.job_id​​ =​​ h.job_id​​ 

WHERE​​ j.enabled​​ =​​ 1 ​​ --Only Enabled Jobs

ORDER​​ by​​ JobName,​​ RunDateTime​​ DESC

 

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter
Bookmark the permalink.

Leave a Reply

Leave a Reply

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