How to: Create a Trace (Transact-SQL)

This topic describes how to use stored procedures to create a trace.

To create a trace

  1. Execute sp_trace_create with the required parameters to create a new trace. The new trace will be in a stopped state (status is 0).

  2. Execute sp_trace_setevent with the required parameters to select the events and columns to trace.

  3. Optionally, execute sp_trace_setfilter to set any or a combination of filters.

    sp_trace_setevent and sp_trace_setfilter can be executed only on existing traces that are stopped.

    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.

See Also

Other Resources

sp_trace_create (Transact-SQL)
sp_trace_setevent (Transact-SQL)
sp_trace_setfilter (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance