Useful Profiler T-SQL functions

Query an individual trace file:

SELECT top 10
*
FROM
::fn_trace_gettable('.trc', default)


Gather Information about running traces:

SELECT * FROM fn_trace_getinfo(null)

 

Stop a trace:

-- Stop a trace. Get the trace ID from the above query
EXEC
master..sp_trace_setstatus @traceid = ? ,@status = 0

 -- Removes a trace definition completely
EXEC
master..sp_trace_setstatus @traceid = ? ,@status = 2

 

 

 

 

 

 

 

 

 

 

 

 
 

Useful Profiler T-SQL functions

Useful Profiler T-SQL functions (start, file to table, getinfo)