SQL Server工具与性能特性全解析
1. 异常记录时间戳查询
在SQL Server中,有时需要获取异常记录的实际日期和时间。以下代码可以实现这一功能:
-- and subtracting this from ms_ticks in sys.dm_os_sys_info which is the
-- number of clock ticks in ms when SQL Server was started
-- and then adding this to the current datetime. This gives you the actual
-- datetime of the record
-- errorno, severity, and state are "shredded" from the XML record
-- errorno from the XML record is joined with sys.sysmessages to get the
-- error message string
-- Not all error messages are "errors". Anything less than severity 16 is
-- "informational"
DECLARE @current_ms_ticks INT
SELECT @current_ms_ticks=ms_ticks FROM sys.dm_os_sys_info
SELECT DATEADD(ms, (orb.timestamp-@current_ms_ticks), GETDATE()) as
[re
超级会员免费看
订阅专栏 解锁全文
1448

被折叠的 条评论
为什么被折叠?



