Convert run duration of sysjobhistory to hh:mm:ss
The run_time 25823 means started at 02:58:23 and run_duration 355 means the job executed for 00:03:55 means 3 minutes 55 seconds
select j.name, step_name, run_date, run_duration,
substring(cast(replicate('0',6-len(run_duration)) + cast(run_duration as varchar) as varchar),1,2) + ':' +
substring(cast(replicate('0',6-len(run_duration)) + cast(run_duration as varchar) as varchar),3,2) + ':' +
substring(cast(replicate('0',6-len(run_duration)) + cast(run_duration as varchar) as varchar),5,2)
as 'hh:mm:ss'
from sysjobs j, sysjobhistory jh where j.job_id = jh.job_id and j.name like 'JobName%'
and jh.step_name like '%outcome%'
order by run_date desc
No comments: