How can I determine the status of a job?

前端 未结 14 2278
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 02:36

I have a Stored procedure which schedules a job. This Job takes a lot of time to get completed (approx 30 to 40 min). I need to get to know the status of this Job. Below det

14条回答
  •  死守一世寂寞
    2020-11-30 02:59

    You could try using the system stored procedure sp_help_job. This returns information on the job, its steps, schedules and servers. For example

    EXEC msdb.dbo.sp_help_job @Job_name = 'Your Job Name'
    

    SQL Books Online should contain lots of information about the records it returns.

    For returning information on multiple jobs, you could try querying the following system tables which hold the various bits of information on the job

    • msdb.dbo.SysJobs
    • msdb.dbo.SysJobSteps
    • msdb.dbo.SysJobSchedules
    • msdb.dbo.SysJobServers
    • msdb.dbo.SysJobHistory

    Their names are fairly self-explanatory (apart from SysJobServers which hold information on when the job last run and the outcome).

    Again, information on the fields can be found at MSDN. For example, check out the page for SysJobs

提交回复
热议问题