O que fazer pra saber quais foram os últimos jobs que tiveram falhas no seu ambiente?
Abaixo postei uma query para simplificar o trabalho de caça aos jobs falhando :)
Como já postei o arquivo em outros sites da internet, vou deixar padrão aqui no meu blog:
--------------------------------------------------------------
/*
Created by - Marcos Rosa
The following select uses the three below tables
from msdb
syscategories: Shows all possible categories
sysjobs: Shows all jobs within the instance
sysjobservers: Shows information for runtime of all jobs
The outcomes information for success or failure of a job is:
0 = Failed
1 = Succeeded
3 = Canceled
5 = Unknown
I used my own aliases to create and label fields feel free to change it at
any time you feel it is reqired.
*/
--------------------------------------------------------------
USE MSDB
SELECT tb.Name, tb.Enabled, tb.Description, tb3.name as Category
, Job_Status =
CASE last_run_outcome
WHEN 0 THEN 'Failed'
WHEN 1 THEN 'Succeeded'
WHEN 3 THEN 'Canceled'
WHEN 5 THEN 'Unknown'
ELSE 'Not for sale'
END , tb2.last_outcome_message as Output_Message
FROM sysjobs as tb, sysjobservers as tb2, syscategories as tb3
WHERE tb.job_id = tb2.job_id and tb.category_id = tb3.category_id
ORDER BY last_run_outcome
Espero que gostem, se tiverem mais informações úteis para a query e estiverem afim de compartilhar, enviem uma nota.
Obrigado e Abraço.
Nenhum comentário:
Postar um comentário