Average Job Execution Time

  • Anyone know of a decent way to get the average time in seconds that a job usually executes?

    I've got this query to display historical info, but the run_duration is in hhmmss format, so taking the average of it when grouped by job name isn't accurate.

    SELECT

    J.name,

    h.run_duration

    FROM

    msdb.dbo.sysjobhistory H

    INNER JOIN msdb.dbo.sysjobs J

    ON H.job_id = J.Job_id

    WHERE

    H.step_name LIKE '%ZIP%'

    ORDER BY J.name

    The Redneck DBA

  • You'd have to cast it out, separate the parts, get the totals.

    So for seconds

    cast( substring( cast(run_duration) as char(6), 5, 2) as int)

    You can get minutes * 60 (for seconds)

    cast( substring( cast(run_duration) as char(6), 4, 2) as int) * 60

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply