如何知道当前正在运行的作业的状态 [英] how to know status of currently running jobs
本文介绍了如何知道当前正在运行的作业的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道给定的Job当前是否在Ms SQL 2008服务器上运行.以免再次调用可能导致并发问题的同一作业.
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.
推荐答案
看起来您可以使用msdb.dbo.sysjobactivity
,检查start_execution_date为非null且stop_execution_date为非null的记录,这意味着该作业已启动,但具有尚未完成.
It looks like you can use msdb.dbo.sysjobactivity
, checking for a record with a non-null start_execution_date and a null stop_execution_date, meaning the job was started, but has not yet completed.
这将为您提供当前正在运行的作业:
This would give you currently running jobs:
SELECT sj.name
, sja.*
FROM msdb.dbo.sysjobactivity AS sja
INNER JOIN msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id
WHERE sja.start_execution_date IS NOT NULL
AND sja.stop_execution_date IS NULL
这篇关于如何知道当前正在运行的作业的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文