Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6081813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:13:04+00:00 2026-05-23T11:13:04+00:00

Previously used this SQL Agent Jobs, how to document to get information about all

  • 0

Previously used this SQL Agent Jobs, how to document to get information about all SQL Scheduled jobs.

How can I find out the duration of the last run for each job? I need seconds, minutes, and hours (hopefully not, but I’m afraid).

Can anyone give some insight into how I could query this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:13:05+00:00Added an answer on May 23, 2026 at 11:13 am

    Assuming you’re not going to have any jobs that run longer than 999 hours, this should give you a good starting point:

    SELECT
        j.name,
        h.run_status,
        durationHHMMSS = STUFF(STUFF(REPLACE(STR(h.run_duration,7,0),
            ' ','0'),4,0,':'),7,0,':'),
        [start_date] = CONVERT(DATETIME, RTRIM(run_date) + ' '
            + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),
            ' ','0'),3,0,':'),6,0,':'))
    FROM
        msdb.dbo.sysjobs AS j
    INNER JOIN
        (
            SELECT job_id, instance_id = MAX(instance_id)
                FROM msdb.dbo.sysjobhistory
                GROUP BY job_id
        ) AS l
        ON j.job_id = l.job_id
    INNER JOIN
        msdb.dbo.sysjobhistory AS h
        ON h.job_id = l.job_id
        AND h.instance_id = l.instance_id
    ORDER BY
        CONVERT(INT, h.run_duration) DESC,
        [start_date] DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ
How does one performance tune a SQL Query? What tricks/tools/concepts can be used to
I haven't been able to find an answer to this question. I used Nu
Previously i working on SQL Server 2005 and i used MARS functionality but currently
count_record=file.readline() count_prev=count_record[:-1] , i used this to read the previous line and it worked
<h:commandLink id=#{id} value=#{value} action=#{actionBean.getAction} onclick=alert(this);/> In the previous simplified example, the 'this' keyword used
I've previously used jquery-ui tabs extension to load page fragments via ajax , and
I'm looking into development standards fro JavaScript. I had previously used Doulgas Crockfords Javascript
The only type of 'remote desktop' application I've used previously is VNC viewer. My
Previously, I used to use MFC collection classes such CArray and CMap . After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.