sql - 如何查询 SQL Server 代理 - 所有作业的错误消息结果集
问题描述
问题:如何查询SQL Server Agent - 所有作业的错误信息结果集
输入:
select *
from [jobs's error masseage table]
where status = 'error' and date between '2020-05-01' and '2020-06-01'
预期结果:
jobname , runtime , status , message
xxx1 , 2020-05-03 , error , #)*)_(#_@$#
xxx2 , 2020-05-05 , error , #)*)_(#_@$#
....
我尝试过并且知道的:我知道Job Activity Monitor
GUI 表单可以做到,但它只包含上次运行,如此屏幕截图所示:
解决方案
我搜索了 msdn 并找到了 dbo.sysjobhistory (Transact-SQL) - SQL Server | Microsoft Docs可以做到
SELECT sj.name,
sh.*
FROM msdb.dbo.sysjobs sj
JOIN msdb.dbo.sysjobhistory sh ON sj.job_id = sh.job_id
where run_status = 0 and run_date between '20200806' and '20200811'
order by run_date
但它看起来只包含几天的数据。
推荐阅读
- google-apps-script - pdf转换器的应用程序脚本超过了最大执行时间
- javascript - 无法运行 npm start reactjs
- python - python gui和/或程序
- tf.keras - 可能无法设置属性“trainable_weights”,因为它与现有的只读@property 冲突
- python - 将 n 3x3 旋转矩阵的数组与 3 向量的 3d 数组相乘
- asp.net - ObjectDataSource 未将 DefaultValue 传递给表适配器
- authentication - ASP.NET Core 3.1 - AddJwtBearer,OnTokenValidated 事件不尊重失败时的自定义消息
- python - Python Pandas DF 按索引将 NaN 替换为来自其他 DF 的值
- c# - UrlHelper 中的 Url.Action 在 ASP.NET Core MVC 中返回错误的 url
- android - 在 Firebase 数据库中更新后,RecycleViewer 未在列表中显示任何内容