zoukankan      html  css  js  c++  java
  • sqlserver job 执行时间

    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

  • 相关阅读:
    MySQL日期比较
    MySQL日期函数、时间函数总结(MySQL 5.X)
    MySQL日期、字符串、时间戳互转
    通过 zxing 生成二维码
    前台时间格式 2019-03-09T16:00:00.000Z
    基于vue-cli配置手淘的lib-flexible + rem,实现移动端自适应
    python爬虫实例大全
    python3 BeautifulSoup模块使用
    Python 通过sgmllib模块解析HTML
    如何搭建一个合理的数值框架?
  • 原文地址:https://www.cnblogs.com/Snowfun/p/7809041.html
Copyright © 2011-2022 走看看