Archive

Posts Tagged ‘sql profiler’

SQL Server: Stop trace using SQL Command

January 15th, 2009 2 comments

Today I started SQL Profiler and paused it. After some time, none of the buttons were enabled. I can neither resume nor stop the trace. Here are the sql commands that I finally found to stop the trace.

1) Get the trace id

SELECT * FROM ::fn_trace_getinfo(default) WHERE property = 2;

2) Stop trace

DECLARE @TraceID int
SET @TraceID = ?
EXEC sp_trace_setstatus @TraceID, 0
EXEC sp_trace_setstatus @TraceID, 2
Categories: SQL Server Tags: ,