The stored procedure that follows, trace_build7, creates a trace from arguments in a text file. The trace_build7 stored procedure is an alternative for using SQL Profiler to create a script to create a trace.
The syntax for trace_build7 is:
@traceini is the name of a text file that contains information for creating a trace. The file name is defined with a data type of nvarchar(245) and has a default value of "C:\ActivityTrace7.ini".
The following example creates a trace from information contained in the Trace1.ini file:
The @traceini file must contain the following information:
Data is written to the trace file specified in this @tracefile variable. Change @tracefile to save the trace to a different drive and file name. Note that a .trc extension is automatically added by the trace.
Change @events to control the events that are traced.
Run the following statement in a query window to get a list of event names and event class numbers:
For example, consider the following contents of a @traceini file that is named TraceArgs.ini: