现在的位置: 首页 > 综合 > 正文

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

2012年10月06日 ⁄ 综合 ⁄ 共 897字 ⁄ 字号 评论关闭

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' 

抱歉!评论已关闭.