笔记50-徐 读取数据库的事务日志增长的trace文件
笔记50-徐 读取数据库的事务日志增长的trace文件
1 读取数据库的事务日志增长的trace文件 事件号是93 2013-6-13 2 DECLARE @tracefile NVARCHAR(MAX) 3 SET @tracefile = ( SELECT LEFT([path], 4 LEN([path]) - CHARINDEX('\', REVERSE([path]))) + '\log.trc' 5 FROM sys.traces 6 WHERE [is_default] = 1 7 ) 8 9 SELECT TOP 100 10 gt.[HostName], gt.[ServerName], gt.[DatabaseName], gt.[SPID], 11 gt.[ObjectName], gt.[objecttype] [ObjectTypeID], 12 sv.[subclass_name] [ObjectType], e.[category_id] [CategoryID], 13 c.[Name] [Category], gt.[EventClass] [EventID], e.[Name] [EventName], 14 gt.[LoginName], gt.[ApplicationName], gt.[StartTime], gt.[TextData] 15 FROM FN_TRACE_GETTABLE(@tracefile, DEFAULT) gt 16 LEFT JOIN sys.trace_subclass_values sv ON gt.[eventclass] = sv.[trace_event_id] AND sv.[subclass_value] = gt.[objecttype] 17 INNER JOIN sys.trace_events e ON gt.[eventclass] = e.[trace_event_id] 18 INNER JOIN sys.trace_categories c ON e.[category_id] = c.[category_id] 19 WHERE gt.[spid] > 50 AND e.[trace_event_id] = 93 20 ORDER BY [StartTime] DESC