A union of curiosity and data science

Knowledgebase and brain dump of a database engineer


Useful Profiler T-SQL functions

Query an individual trace file:

SELECT top 10
*
FROM
::fn_trace_gettable('<drive><path><file>.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