There are 2 ways to view SQL Job History.

via GUI

Job -> View History

via Script

SELECT 
	TOP 1000
	  j.name
	, jh.server
	, jh.run_date
	, jh.run_time
	, jh.step_id
	, jh.run_status
	, jh.run_duration
	, jh.message
	, jh.sql_message_id
	, jh.sql_severity
FROM 
	[msdb].[dbo].[sysjobhistory] jh
	JOIN [msdb].[dbo].[sysjobs] j ON jh.job_id= j.job_id
WHERE 
	j.name='Job 01'
	AND
	jh.run_status IN (0,1) -- Job Result Status
ORDER BY
	jh.run_date DESC, jh.run_time DESC, jh.step_id DESC
Last modified: December 13, 2019

Author

Comments

Write a Reply or Comment