list of SQL Agent Jobs failed in last 7 days


USE [msdb];

GO

SELECT DISTINCT

       j.name 'job_name',

       count(h.run_date) 'failed_runs_last_7' --h.run_duration

FROM

       sysjobs j    

       JOIN sysjobhistory h on j.job_id = h.job_id

WHERE

       j.enabled = '1'

       and h.run_status = '0'

       and h.step_id = '0'

       and h.run_date >= CONVERT(VARCHAR(8), GETDATE(), 112) - 7 -- past 7 days

GROUP BY

       j.name

ORDER BY

       j.name

Comments

Post a Comment

Hi User,
Thanks for visiting My Blog and please provide your valuable feedback and subscribe for more updates. Please don't post any spam content or comments.
Thank You

Popular Posts

Failed to execute the package or element. Build errors were encountered

Exception deserializing the package "The process cannot access the file because it is being used by another process."

Temporary enable and disable SSRS subscriptions