问题描述
我使用以下 SQL 列出了所有没有停止日期的作业.我想我可以用它来找到所有活跃的工作.我注意到我在这个表中有许多作业的 stop_execution_date 为空.某些相同的作业(相同的 job_id)在此表中重复多次.
I had used the following SQL to list out all jobs without a stop date. I thought that I could use this to find all active jobs. What I noticed is that I have a number of jobs in this table with a null stop_execution_date. Some identical jobs (same job_id) are repeated multiple times in this table.
select job.*, activity.*
from msdb.dbo.sysjobs_view job
inner join msdb.dbo.sysjobactivity activity
on (job.job_id = activity.job_id)
where run_Requested_date is not null and stop_execution_date is null
当我对这些作业运行 EXEC msdb.dbo.sp_help_job
时,我看到它们当前的执行状态是空闲的.
When I run EXEC msdb.dbo.sp_help_job
on these jobs, I see that they the current execution status is idle.
这些工作代表什么?这是作业没有正确终止时的行为吗?
What do these jobs represent? Is this the behavior when the jobs are not killed properly?
推荐答案
每次 SQL 代理启动时,它都会在 syssessions 中放置一个新行,随后运行的任何作业都会在 sysjobactivity 中获得该 session_id.对于停止日期为空的作业,我的猜测是它们不适用于当前"会话,这意味着它们在代理停止时仍在运行.
Each time the SQL Agent starts, it puts a new row in syssessions and subsequently any jobs run will get that session_id in sysjobactivity. For your jobs that have a null stop date, my guess is that they're not for the "current" session which would mean that they were still running when the agent was stopped.
这篇关于停止日期为空的工作意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!