Run times of jobs

  • Hi Guys,

    Does anyone perhaps have a script or know of anyway I can check what the run times are a specific jobs.

    When looking at properties it only shows the schedules but we need to find out how long a particular job runs.

    Regards

  • Hi there,

    The following script should get you the information you need:

    USE

    msdb;

    EXECUTE

    msdb..[sp_help_jobhistory]

    This will give you the history of the jobs + run time, you should be able to insert this into a temp table and perform any selects/processing you need to. Watch out for failed job's durations etc as these can be 0.

    Hope this helps,

    - James

    --
    James Moore
    Red Gate Software Ltd

  • thanx for ur help

    but we usually cjheck the view job history to view how long the job has run. what i need to know is, when u start a job, is there maybe a script that can tell u what the current running time status.

     

    Regards

  • I dont think there is a direct way to get that, Because jobs are basically used for scheduling purposes. At the background what it does it executes SQL statements.

     Hence if you relly wana do that you need to check the sysprocess table for that particular SPID ( which was started by SQL agent). But note that the SPIDs will change from time to time

  • You can run sp_help_jobhistory (MSDB) and it will return runtimes/jobnames etc if you really want to get specific you can open up the proc and see where it pulls its info..

    Hope this helps!

  • Maybe I am missing something.. but in SSMgt Studio, SQL Agent, jobs. If you select the specific job history it is there... have to scroll to the right to see duration. Also, if you select the specific run it does show the output on the bottom pane and it shows duration in seconds there as well.

Viewing 6 posts - 1 through 5 (of 5 total)

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