How to Get All Server Side Traces in SqlServer from SSMS(Active,Inactive), stop it from SSMS and delete the log files.
I need all traces saving into file as well as table.
I tried SELECT * FROM fn_trace_getinfo(DEFAULT). Some times few parameters are NULL. What does it mean ?
Best Answer
Trace properties with
NULL
values indicate options were not specified when the trace was created. Properties are listed in the fn_trace_getinfo documentation and can be included a query for easy reference:Rowset traces (Profiler or SMO) will not have values pertaining to server-side traces, such as file name, max size, etc. Below are example results of the above query including the default trace and a running Profiler trace.
The trace properties are also exposed as normalized columns in
sys.traces
. This DMV includes all legacy SQL Traces (but not Extended Event traces) regardless of whether its a server-side trace to a file or rowset trace returning data to a Profiler client. You may find it easier to query sys.traces instead. Example output fromSELECT * FROM sys.traces
.EDIT:
A trace can be stopped and deleted in SSMS by executing
sp_trace_setstatus
from a query window, specifying the desired trace id and status (0 = stop, 2 = delete). For example, the rowset trace withtraceid
2 above can be stopped and deleted with: