Uma das primeiras coisas que costumo fazer ao iniciar minhas atividades como DBA SQL Server é verificar meus e-mails para identificar os jobs que falharam na última noite. Porém o problema é que juntamente com os jobs que falharam, apareciam todos que rodaram com sucesso, então resolvi não encher mais a caixa de entrada usando apenas um procedimento para filtrar apenas os jobs que tiveram falha.
Com o script abaixo você poderá colocar o resultado em uma tabela para consultar depois, ou criar um procedimento para enviar por e-mail, assim você terá apenas as informações que precisa em apenas um e-mail.
Veja o script abaixo.
DECLARE @OneDayAgo INT = CONVERT(INT, Dateadd(dd, -1, Getdate()), 112); SELECT j.NAME, s.step_name, h.step_id, h.step_name, CONVERT(DATE, Cast(h.run_date AS VARCHAR(8)), 111) run_date, Stuff(Stuff(RIGHT(Cast(h.run_time + 1000000 AS VARCHAR(8)), 6), 3, 0, ':' ), 6, 0 , ':') AS run_time, h.message, h.server FROM msdb.dbo.sysjobhistory h INNER JOIN msdb.dbo.sysjobs j ON h.job_id = j.job_id INNER JOIN msdb.dbo.sysjobsteps s ON j.job_id = s.job_id AND h.step_id = s.step_id WHERE h.run_status = 0 -- did the job fail AND h.run_date > @OneDayAgo ORDER BY h.instance_id DESC;
Port video games have actually long been a popular type of entertainment, providing exhilarating gameplay…
When it pertains to online gambling, safety needs to be a top issue for every…
There are many reasons to play no-cost online casino games in the coming year. The…
On the internet casinos have acquired tremendous appeal in recent times, offering gamers with the…
Welcome to our useful post concerning the very best casino site game! Whether you're a…
The random number generator (or RNG) is the program that generates the outcome of every…