Friday, March 16, 2012

SQL Server Trace Related Information


To find traceid       -- SELECT * FROM :: fn_trace_getinfo(default)
To start a trace      -- sp_trace_setstatus traceid, 1
To stop a trace      -- sp_trace_setstatus traceid, 0
To close and delete a trace   --   sp_trace_setstatus traceid,0
                                                  sp_trace_setstatus traceid, 2

Modifies the current state of the specified trace.

sp_trace_setstatus [ @traceid = ] trace_id , [ @status = ] status
sp_trace_setstatus 2, 2

Status  Description
0 Stops the specified trace.
1 Starts the specified trace.
2 Closes the specified trace and deletes its definition from the server.

Property int Description of the trace:

1= Trace options. For more information, see @options in sp_trace_create (Transact-SQL).
2 = File name
3 = Max size
4 = Stop time
5 = Current trace status. 0 = stopped. 1 = running.

No comments: