I have a single step job that executes a stored procedure. I would like get the date of the last successful job execution time so that I can just update a delta instead of the w
To get Last successfully run jobs:
SELECT
h.[job_id]
,j.Name JobName
,CONVERT(CHAR(10), CAST(STR(run_date,8, 0) AS dateTIME), 111) [LastRunDate]
,STUFF(STUFF(RIGHT('000000' +
CAST (run_time AS`` VARCHAR(6 ) ) ,6),5,0,':'),3,0,':') [LastRunTime]
,CASE run_status
WHEN 0 THEN 'Failed'
WHEN 1 THEN 'Succeeded'
WHEN 2 THEN 'Retry'
WHEN 3 THEN 'Cancelled'
WHEN 4 THEN 'In Progress'
END AS ExecutionStatus
FROM [msdb].[dbo].[sysjobhistory] h
JOIN msdb.dbo.sysjobs j ON h.job_id=j.job_id
WHERE run_status=1
ORDER BY run_date DESC,run_time DESC