how to know status of currently running jobs

前端 未结 9 1279
难免孤独
难免孤独 2020-12-24 04:43

I need to know if a given Job is currently running on Ms SQL 2008 server. So as to not to invoke same job again that may lead to concurrency issues.

9条回答
  •  一生所求
    2020-12-24 05:30

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

    check field execution_status

    0 - Returns only those jobs that are not idle or suspended.
    1 - Executing.
    2 - Waiting for thread.
    3 - Between retries.
    4 - Idle.
    5 - Suspended.
    7 - Performing completion actions.

    If you need the result of execution, check the field last_run_outcome

    0 = Failed
    1 = Succeeded
    3 = Canceled
    5 = Unknown

    https://msdn.microsoft.com/en-us/library/ms186722.aspx

提交回复
热议问题