Skip to content

fn_trace_gettable

How to read a .trc trace file back into a table, with and without event class names.

Published Jun 23, 2008

Once a trace file exists, fn_trace_gettable is how you get the data out. The first query reads the whole file as-is; the second joins sys.trace_events on EventClass so each row carries a readable event name instead of just the numeric id - which makes any subsequent filtering and aggregation much more pleasant.

select * from fn_trace_gettable('C:\File.trc', default)

select
	TE.name as EventName,
	T.*
from
	fn_trace_gettable('C:\File.trc', default) as T
JOIN sys.trace_events TE
	ON T.EventClass = TE.trace_event_id
An unhandled error has occurred. Reload 🗙