how to know status of currently running jobs

前端 未结 9 1316
难免孤独
难免孤独 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条回答
  •  旧时难觅i
    2020-12-24 05:10

    EXECUTE master.dbo.xp_sqlagent_enum_jobs 1,''
    

    Notice the column Running, obviously 1 means that it is currently running, and [Current Step]. This returns job_id to you, so you'll need to look these up, e.g.:

    SELECT top 100 *
     FROM   msdb..sysjobs
     WHERE  job_id IN (0x9DAD1B38EB345D449EAFA5C5BFDC0E45, 0xC00A0A67D109B14897DD3DFD25A50B80, 0xC92C66C66E391345AE7E731BFA68C668)
    

提交回复
热议问题