查询作业的执行情况sql:
SELECT [JobName] = JOB.name, [Step] = HIST.step_id, [StepName] = HIST.step_name, [Message] = HIST.message, [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed' WHEN HIST.run_status = 1 THEN 'Succeeded' WHEN HIST.run_status = 2 THEN 'Retry' WHEN HIST.run_status = 3 THEN 'Canceled' END, [RunDate] = HIST.run_date, [RunTime] = HIST.run_time, [Duration] = HIST.run_duration FROM msdb.dbo.sysjobs JOB INNER JOIN msdb.dbo.sysjobhistory HIST ON HIST.job_id = JOB.job_id --WHERE JOB.name = 'jobname' ORDER BY HIST.run_date desc, HIST.run_time
step:作业的第几个步骤。其中0为结果。
step:对应步骤的名字。
即是查作业的历史记录。