List out jobs and last run times on SQL 2013
Richard
September 29, 2014
Uncategorized
Comments Off on List out jobs and last run times on SQL 2013
Tags: SQL Server 2013
Generate a table of jobs and their last run times on SQL Server 2013.
use msdb
;WITH jobhistory as (
SELECT job_id,
run_status,
last_run_time = max(dbo.agent_datetime(run_date, run_time))
FROM msdb.dbo.sysjobhistory
WHERE step_id = 0
AND run_status = 1
GROUP BY job_id, run_status)
SELECT j.job_id,
j.name,
jh.run_status,
jh.last_run_time
FROM msdb.dbo.sysjobs j
LEFT OUTER JOIN jobhistory jh
ON j.job_id = jh.job_id
ORDER BY j.name ASC