Get date of last successful job run?

前端 未结 5 2205
日久生厌
日久生厌 2021-02-20 16:09

I have a single step job that executes a stored procedure. I would like get the date of the last successful job execution time so that I can just update a delta instead of the w

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-20 17:01

    Have a look at this article, it may point you in the right direction. Unfortunately I don't have SQL Server on my home machine so can't test it out for you!

    You basically need to query the sysjobactivity table and get the values from start_execution_date and stop_execution_date. You'll need the job_id, but i'm not sure where you'll get that from.

    I hope this helps.

    EDIT Ok, I've done some more research and found the following code snippet

    DECLARE @jobId binary(16)
    
    SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'Name of Your Job')
    

提交回复
热议问题