try this,select a.name 'JobName',c.run_date,c.run_time,c.message from msdb.dbo.sysjobs a inner join msdb.dbo.sysjobsteps b on a.job_id=b.job_id inner join msdb.dbo.sysjobhistory c on a.job_id=c.job_id
select j.name as job_name,
js.step_name,
h.run_date, h.run_time, h.run_duration, h.server,
case run_status when 0 then '失败' when 1 then '成功' when 2 then '重试' when 3 then '取消' when 4 then '正在进行' end as run_status
from msdb.dbo.sysjobhistory hinner join msdb.dbo.sysjobs j on h.job_id = j.job_id
inner join msdb.dbo.sysjobsteps js on js.job_id = h.job_id and js.step_id = h.step_id
from msdb.dbo.sysjobs a
inner join msdb.dbo.sysjobsteps b on a.job_id=b.job_id
inner join msdb.dbo.sysjobhistory c on a.job_id=c.job_id
js.step_name,
h.run_date,
h.run_time,
h.run_duration,
h.server,
case run_status
when 0 then '失败'
when 1 then '成功'
when 2 then '重试'
when 3 then '取消'
when 4 then '正在进行'
end as run_status
from msdb.dbo.sysjobhistory hinner join msdb.dbo.sysjobs j
on h.job_id = j.job_id
inner join msdb.dbo.sysjobsteps js
on js.job_id = h.job_id
and js.step_id = h.step_id