Knowledge.ToString()

Stop SQL Server Trace Using SQL Command

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.

Get the trace id

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

Stop trace

DECLARE @TraceID int
SET @TraceID = ?
EXEC sp_trace_setstatus @TraceID, 0
EXEC sp_trace_setstatus @TraceID, 2

Share

Comments

5 responses to “Stop SQL Server Trace Using SQL Command”

  1. Hestabit Technologies Avatar
    Hestabit Technologies

    I used this code and it worked perfectly

  2. MAKAROV Avatar
    MAKAROV

    Thanks for sharing

  3. ramengo Avatar
    ramengo

    Thanks. it worked perfctly.

  4. geeks Avatar
    geeks

    Humm… interesting,

    works good

    Keep up the good work

  5. Michael B Avatar
    Michael B

    Many thanks! Worked like a charm.

Leave a Reply

Your email address will not be published. Required fields are marked *