Blog Pages

Average SQL jobs duration

select h.job_id,
       avg ((      (h.run_duration % 100) -- Seconds
           + 60 * ((h.run_duration /100) % 100) -- + minutes to seconds
           + 3600 * ((h.run_duration / 10000) % 100) -- + Hours to seconds
            )
             ) as AvgJobDuration_Seconds
from   msdb.dbo.sysjobhistory h
where h.step_id = 0
group by h.job_id

No comments:

Post a Comment