检查SQL Server Job状态
程序员文章站
2022-03-20 10:07:42
...
检查SQLServerJob状态 无 exec msdb.dbo.sp_help_job @execution_status=1 select distinct j.Name as "Job Name", j.description as "Job Description", h.run_date as LastStatusDate, h.run_time as LastStatusTime, h.run_duration as LastStatusDuration
检查SQL Server Job状态exec msdb.dbo.sp_help_job @execution_status=1
select distinct j.Name as "Job Name", j.description as "Job Description", h.run_date as LastStatusDate, h.run_time as LastStatusTime, h.run_duration as LastStatusDuration, case h.run_status when 0 then 'Failed' when 1 then 'Successful' when 3 then 'Cancelled' when 4 then 'In Progress' end as JobStatus from msdb..sysJobHistory h, msdb..sysJobs j where j.job_id = h.job_id and h.step_id = 1 and h.run_date = (select max(hi.run_date) from msdb..sysJobHistory hi where h.job_id = hi.job_id) and h.run_time = (select max(hj.run_time) from msdb..sysJobHistory hj where h.job_id = hj.job_id) order by 1
select distinct cat.name as "Category", j.Name as "Job Name", j.description as "Job Description", h.run_date as LastStatusDate, h.run_time as LastStatusTime, h.run_duration as LastStatusDuration, case h.run_status when 0 then 'Failed' when 1 then 'Successful' when 3 then 'Cancelled' when 4 then 'In Progress' end as JobStatus from msdb..sysJobHistory h, msdb..sysJobs j, msdb..syscategories cat where j.job_id = h.job_id and j.category_id = cat.category_id and h.step_id = 1 and h.run_date = (select max(hi.run_date) from msdb..sysJobHistory hi where h.job_id = hi.job_id) and h.run_time = (select max(hj.run_time) from msdb..sysJobHistory hj where h.job_id = hj.job_id) order by 1,3
Select [Job Name] = j.name , [Job Description] = j.description , [LastRunDate] = h.run_date , [LastRunTime] = h.run_time , [JobStatus] = Case h.run_status When 0 Then 'Failed' When 1 Then 'Successful' When 3 Then 'Cancelled' When 4 Then 'In Progress' End ,[OrderOfRun] = Rank() Over(Partition By j.job_id Order By h.run_date Desc,h.run_time Desc) From msdb.dbo.sysjobhistory h Left join msdb.dbo.sysjobs j On j.job_id = h.job_id Where h.step_id=0 --only look @ Job Outcome step Order By [Job Name] desc,Rank() Over(Partition By j.job_id Order By h.run_date Desc,h.run_time Desc) Asc
上一篇: 有关个语言基本技术的介绍
下一篇: java环境配置的详细教程(图文)
推荐阅读
-
sql server定时作业调用Kettle job出错的快速解决方法
-
将MS SQL SERVER数据库运行在普通用户(独立用户)状态下的设置方法终结篇
-
将MS SQL SERVER数据库运行在普通用户(独立用户)状态下的设置方法终结篇
-
SQL Server DBA日常检查常用SQL
-
SQL Server中检查字段的值是否为数字的方法
-
SQL Server 版本变更检查 警告
-
sql server启动不了, MSSQL 18052错误: 9003,严重度: 20,状态: 1 .
-
SQL Server 版本变更检查 警告
-
SQL Server DBA日常检查常用SQL
-
SQL Server中检查字段的值是否为数字的方法