查看SqlServer数据库JOB执行情况语句

select   J.name   作业名称,P.step_id 步骤编号,P.step_name 步骤名称,P.command 执行命令,
                case   J.enabled
                        when   0   then   '禁用 '
                        when   1   then   '启用 '
                        else   ' '   end   状态,
                case   P.last_run_outcome
                        when   0   then   '失败 '
                        when   1   then   '成功 '
                        else   ' '   end   上次执行,
                          P.last_run_duration 执行时间秒,
                          str(last_run_date)+ '   '+stuff(stuff(right( '000000 '+ltrim(str(last_run_time)),6),3,0, ': '),7,0, ': ')  上次启动时间 ,
    str(s.next_run_date)+ '   '+stuff(stuff(right( '000000 '+ltrim(str(s.next_run_time)),6),3,0, ': '),7,0, ': ')  下次启动时间 ,
    P.database_name AS 数据库
    
    from   msdb.dbo.sysjobschedules   S
  inner   join   msdb.dbo.sysjobs   J   on   S.job_id   =   J.job_id
  inner   join   msdb.dbo.sysjobsteps   P   on   S.job_id   =   P.job_id where P.database_name='DBName' 

转载于:https://www.cnblogs.com/ly360/archive/2011/10/27/2226561.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值