Wednesday, July 10, 2013

0 Query default trace

 

List trace category and event name

SELECT te.category_id,tc.name,te.trace_event_id,te.name FROM 
  sys.trace_events te,    sys.trace_categories tc
  WHERE te.category_id = tc.category_id

image

 

Query Default trace

 

SELECT   tc.name,te.name,ftg.DatabaseID,DB_NAME(ftg.databaseid),ftg.LoginName,ftg.HostName,ftg.ClientProcessID,ftg.spid,ftg.ApplicationName,ftg.StartTime,ftg.EndTime,
ftg.ObjectID,
ftg.ObjectName,ftg.ServerName,ftg.EventClass,ftg.Error,ftg.TextData
FROM   ::fn_trace_gettable(CONVERT(VARCHAR(150), ( SELECT TOP 1 f.[value] FROM sys.fn_trace_getinfo(NULL) f WHERE f.property = 2)), DEFAULT) AS ftg 
INNER   JOIN sys.trace_events AS te ON ftg.EventClass = te.trace_event_id  
INNER JOIN sys.trace_categories AS tc ON tc.category_id = te.category_id
ORDER BY   ftg.StartTime

 

image

 

SQL server trace: http://www.sqlpanda.com/2012/11/sql-server-trace.html

0 comments:

Post a Comment

 

SQL Panda Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates