Tuesday, December 11, 2012

How to list traces and stop from SQL Server?

How to list traces and stop from SQL Server?

We often create custom traces to capture some information on sql server and most of the times we forgot to stop them.

Following query will list all the traces which are running on a SQLServer.

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

Copy the Trace id which you want to stop trace and feed that in below query and execute it.

DECLARE @TraceID int
SET @TraceID = <input the Trace id value from above query>
EXEC sp_trace_setstatus @TraceID, 0
EXEC sp_trace_setstatus @TraceID, 2

No comments:

Post a Comment