Home > SQL Server > SQL Server: Stop trace using SQL Command

SQL Server: Stop trace using SQL Command

January 15th, 2009 Leave a comment Go to 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: ,
  1. Michael B
    March 12th, 2009 at 14:40 | #1

    Many thanks! Worked like a charm.

  2. August 14th, 2009 at 03:07 | #2

    Humm… interesting,

    works good

    Keep up the good work

  3. ramengo
    September 1st, 2010 at 11:09 | #3

    Thanks. it worked perfctly.

  1. No trackbacks yet.