select instance_id,jh.run_date,jh.job_id,jh.step_name,
    case jh.run_status
        when 0 then 'failed'
        when 1 then 'Succeeded'
        when 2 then 'Retry'
        when 3 then 'Canceled'
    end as run_status
    
    ,left(jh.run_time,len(jh.run_time)-2) as '开始时间' 
    ,left(run_duration,len(run_duration)-2) as '',right(run_duration,2) as '',jh.run_duration,jh.run_time
from msdb.dbo.sysjobhistory jh with(nolock)
where job_id=N'1C8F16AC-5C37-4D76-883F-CD318A9E19D6' and 
step_name='OUT2SAP_Without_PR' and jh.run_status=1
order by instance_id desc

 

select * from (select instance_id,jh.run_date,jh.job_id,jh.step_name,
    case jh.run_status
        when 0 then 'failed'
        when 1 then 'Succeeded'
        when 2 then 'Retry'
        when 3 then 'Canceled'
    end as run_status
    
    ,left(jh.run_time,len(jh.run_time)-2) as '开始时间' 
    ,left(run_duration,len(run_duration)-2) as '',right(run_duration,2) as '',jh.run_duration,jh.run_time
from msdb.dbo.sysjobhistory jh with(nolock)
where job_id=N'1C8F16AC-5C37-4D76-883F-CD318A9E19D6' and 
step_name='OUT2SAP_Without_PR' and jh.run_status=1
--order by instance_id desc

union all  
select instance_id,jh.run_date,jh.job_id,jh.step_name,
    case jh.run_status
        when 0 then 'failed'
        when 1 then 'Succeeded'
        when 2 then 'Retry'
        when 3 then 'Canceled'
    end as run_status
    
    ,left(jh.run_time,len(jh.run_time)-2) as '开始时间' 
    ,left(run_duration,len(run_duration)-2) as '',right(run_duration,2) as '',jh.run_duration,jh.run_time
from msdb.dbo.sysjobhistory jh with(nolock)
where --job_id=N'1C8F16AC-5C37-4D76-883F-CD318A9E19D6' and 
step_name='AutoOut2Sap_Without_SO' and jh.run_status=1
--order by instance_id desc

) A order by instance_id desc

sqlserver job 执行时间

 

相关文章:

  • 2021-12-18
  • 2021-07-09
  • 2022-01-05
  • 2021-07-29
  • 2021-12-15
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2022-01-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
相关资源
相似解决方案