Created
September 17, 2015 19:38
-
-
Save franklinbr/e090a5482aba18e77ec5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT | |
' a '+SUBSTRING(CAST(run_date AS VARCHAR(10)), 7,2) + '/' + SUBSTRING(CAST(run_date AS VARCHAR(10)), 5,2)+ '/' + SUBSTRING(CAST(run_date AS VARCHAR(10)), 1,4), | |
+' aa '+CASE run_status WHEN 1 THEN '<span class="sucesso">Sucesso</span>' WHEN 0 THEN '<span class="falhou">Falhou</span>' WHEN 3 THEN '<span class="cancelado">Cancelado</span>' END, | |
+' bb '+sj.name 'Job', | |
+' cc '+(SELECT Min(message) FROM msdb.dbo.sysjobhistory A WHERE A.job_id = sj.job_id AND A.run_status IN (0,3)) | |
FROM msdb.dbo.sysjobs sj | |
INNER JOIN msdb.dbo.sysjobsteps sjs ON sjs.job_id = sj.job_id | |
INNER JOIN msdb.dbo.sysjobhistory sjh ON sj.job_id = sjh.job_id | |
AND CONVERT(VARCHAR(10), sjh.run_date, 112) >= CONVERT(VARCHAR(10), GETDATE()-1, 112) | |
--order by run_date desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment