How to check if one of the sql job is running for long time

  • Hi,

    I have a job which sends the daily report by fetching the information from the Database, some times the sql job is running for long time and it will not send the mail by fetching the information, at that i have to restart the SQL Server and SQL Server Agent manually and then it works.

    Now i would like to check if any of the sql job is running for long time and restart both SQL Server and SQL Server agent so that my job of restarting the services manually will be automated.

    With Regards

    Dakshina Murthy

  • This article will help you identify the long running jobs. Although, you should probably do some more troubleshooting and look for any blocking before restarting SQL Server. You really shouldn't have to restart SQL Server to make a job run.

    How to Find Long Running SQL Agent Jobs

  • Thanks a lot i will check with this, sorry for asking how to restart the sql server, i would like to restart the sql sever agent.

    With Regards

    Dakshina Murthy

  • Another option is to check the SYSJOBHISTORY system table, but there is a trick to use it.

    The sysjobhistory record is created only when a job STEP finish, so you can add a FIRST STEP in you job (a FAKE step).

    For example: SELECT GETDATE() as a first step.

    So, you can JOIN system tables and get the running elapsed time.

    ---------------------
    Alex Rosa
    http://www.keep-learning.com/blog

  • Hey,

    Thanks a lot for the reply, i will try working on this, Thanks for the input once again.

    With Regards

    Dakshina Murthy

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

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