SQL Server作业信息和作业的调度控制简析(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-26 22:15 点击:次
FROM msdb.dbo.sysjobhistory
WHERE job_id = sysjobs.job_id
ORDER BY instance_id DESC),
作业或步骤开始的时间 = (SELECT top 1 left(left(left('000000',6-len(run_time))+ltrim(run_time),2)+':'+right(left('000000',6-len(run_time))+ltrim(run_time),4),5)+':'+right(left('000000',6-len(run_time))+ltrim(run_time),2)
FROM msdb.dbo.sysjobhistory
WHERE job_id = sysjobs.job_id
ORDER BY instance_id DESC),
执行作业或步骤所花费的时间 = (SELECT top 1 left(left(left('000000',6-len(run_duration))+ltrim(run_duration),2)+'小时'+right(left('000000',6-len(run_duration))+ltrim(run_duration),4),5)+'分钟'+right(left('000000',6-len(run_duration))+ltrim(run_duration),2)+'秒'
FROM msdb.dbo.sysjobhistory
WHERE job_id = sysjobs.job_id
ORDER BY instance_id DESC)
FROM msdb.dbo.sysjobs
三、某一个作业的详情(如:NOAS.DW 的20120411 执行情况)
[sql]
select 作业名称=tb.name,步骤=ta.step_name,
错误的严重级别=ta.sql_severity,
消息=ta.message,
执行状态=case when run_status=0 then '失败'
when run_status=1 then '成功'
when run_status=2 then '重试'
when run_status=3 then '已取消' end,
重试次数=retries_attempted,
步骤顺序=ta.step_id, www.2cto.com
花费的时间=substring(right('000000'+ltrim(ta.run_duration),6),1,2)+':'+SUBSTRING(right('000000'+ltrim(ta.run_duration),6),3,2)+':'+RIGHT(right('000000'+ltrim(ta.run_duration),6),2)
from dbo.sysjobhistory ta,sysjobs tb
where ta.job_id=tb.job_id and tb.name='NOAS.DW'
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>