Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
How to: Create a Trace (Transact-SQL)
Collapse the table of content
Expand the table of content

How to: Create a Trace (Transact-SQL)

This topic describes how to use stored procedures 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.

    ms188662.note(en-US,SQL.90).gifImportant:
    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.

Community Additions

ADD
Show:
© 2015 Microsoft