Long running sql jobs

Jinal Contractor 121 Reputation points
2021-01-14T20:29:05.48+00:00

I'd like to know or need to find out more about the long running jobs (anything over a couple of minutes)
Is there a way to use it to generate a list of stats from the various procs in a day?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,865 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Cris Zhan-MSFT 6,631 Reputation points
    2021-01-15T02:19:56.86+00:00

    Hi @Jinal Contractor ,

    The following script can return the execution time of the sql jobs. For jobs that are still running incomplete, the column Duration is displayed as null.

    SELECT sj.name,   
     sja.run_requested_date,   
     CONVERT(VARCHAR(12), sja.stop_execution_date-sja.start_execution_date, 114) Duration  
    FROM msdb.dbo.sysjobactivity sja  
    INNER JOIN msdb.dbo.sysjobs sj  
    ON sja.job_id = sj.job_id  
    WHERE sja.run_requested_date IS NOT NULL  
    ORDER BY sja.run_requested_date desc;  
    

    You can use SSMS>SQL Server Agent>Reports to find some details on top jobs(slowest jobs,etc).

    0 comments No comments

  2. Shashank Singh 6,251 Reputation points
    2021-01-15T07:28:49.013+00:00

    (anything over a couple of minutes)

    Who told you to check jobs anything running over minute ?. Even if you do get a query what purpose will it server. Please first define a correct approach and what you qualify as long running job

    Is there a way to use it to generate a list of stats from the various procs in a day?

    Sorry did not get this part of your question. Please explain

    0 comments No comments

  3. Julia Baker 0 Reputation points
    2023-03-07T12:54:32.4+00:00

    I hope you came right. If you are in SQL, this may help you

    https://www.executiveplacements.com/Jobs/sql-developer-jobs.asp

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.