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
Thank you for the information
ReplyDeleteThanks for your feedback
DeleteNice information
ReplyDeleteThanks for your feedback
Delete