根据JOB名称查询该JOB是否正在执行中
executestatus 是1是正在执行,0是未执行。
USE msdb;
DECLARE @temp TABLE
(
session_id INT ,
job_id UNIQUEIDENTIFIER ,
job_name sysname ,
run_requested_date DATETIME ,
run_requested_source sysname ,
queued_date DATETIME ,
start_execution_date DATETIME ,
last_executed_step_id INT ,
last_exectued_step_date DATETIME ,
stop_execution_date DATETIME ,
next_scheduled_run_date DATETIME ,
job_history_id INT ,
message NVARCHAR(1024) ,
run_status INT ,
operator_id_emailed INT ,
operator_id_netsent INT ,
operator_id_paged INT
);
INSERT INTO @temp
EXEC sp_help_jobactivity @job_name = N'82诊断脑膜瘤';
SELECT executestatus = CASE WHEN stop_execution_date IS NULL THEN 1
ELSE 0
END ,
*
FROM @temp;