Modify an Existing Trace (Transact-SQL)

 

Applies To: SQL Server 2016

This topic describes how to use stored procedures to modify an existing trace.

To modify an existing trace

  1. If the trace is already running, execute sp_trace_setstatus by specifying @status = 0 to stop the trace.

  2. To modify trace events, execute sp_trace_setevent by specifying the changes through the parameters. Listed in order, the parameters are:

    • @traceid (Trace ID)

    • @eventid (Event ID)

    • @columnid (Column ID)

    • @on (ON)

    When you modify the @on parameter, keep in mind its interaction with the @columnid parameter:

    ONColumn IDResult
    ON (1)NULLEvent is turned on. All columns are cleared.
    NOT NULLColumn is turned on for the specified event.
    OFF (0)NULLEvent is turned off. All columns are cleared.
    NOT NULLColumn is turned off for the specified event.
System_CAPS_ICON_important.jpg Important


Unlike regular stored procedures, parameters of all SQL Server Profiler stored procedures (sp_trace_xx**) are strictly typed and do not support automatic data type conversion. If these parameters are not called with the correct input parameter data types, as specified in the argument description, the stored procedure returns an error.

sp_trace_setevent (Transact-SQL)
sp_trace_setstatus (Transact-SQL)
System Stored Procedures (Transact-SQL)
SQL Server Profiler Stored Procedures (Transact-SQL)

Community Additions

ADD
Show: