Creating Traces

Traces can be created using either SQL Server Profiler, Microsoft® SQL Server extended stored procedures, or the Create Trace Wizard. You can create one or more traces using any combination of SQL Server Profiler event classes and event class criteria.

Before creating a trace using SQL Server Profiler, you can specify default trace values in the Options dialog box. The default trace values for SQL Server Profiler are:

Additionally, you can specify default display values that determine how SQL Server Profiler displays the running traces, such as starting the trace as soon as it is created, the number of text lines displayed when an event is expanded, the size of the trace buffer, and the font to use.


Note If the trace buffer size is exceeded, the oldest events will be deleted from the trace to allow new events to be captured. The trace buffer size does not apply to traces saved to a file or table.


When creating a trace using SQL Server Profiler, specify:

The Create Trace Wizard can create predefined traces that can be used to monitor common problems, such as finding poorly performing queries quickly, identifying large table scans, tracking application, user, and stored procedure usage and performance, and detecting and analyzing deadlocks.

Using Extended Stored Procedures

SQL Server Profiler uses extended stored procedures to create traces from the selections you enter in the user interface. The extended stored procedures are used to create the queues to store events and send the trace output to the appropriate destination. These extended stored procedures can be used from within your own applications to create traces manually, instead of using SQL Server Profiler. This allows you to write custom applications specific to the needs of your enterprise that monitor SQL Server. For example, when using extended stored procedures to create traces, you can:

Extended stored procedures expose the underlying architecture used to create traces. The architecture components are:

Producer
Generates the events to be monitored. An example of a producer is the SQL Server lock manager, which generates lock events. For more information, see Locks Event Category.
Filter
Restricts the data monitored by the trace. For more information, see Filtering Events.
Queue
Collects event data and queues the events for asynchronous processing by consumers. The consumer extracts the events from the queue. For example, the file consumer extracts the events from the queue and writes them to a destination file.
Destination
The place to send the event data when extracted from the queue. Destinations include files, SQL Server tables, other computers running SQL Server, and the Windows NT application log.

The general steps required to define your own trace using extended stored procedures are:

  1. Create a new queue using xp_trace_addnewqueue.
  2. Specify the events to capture using xp_trace_seteventclassrequired.
  3. Specify any event filters.For more information, see How to set a trace filter (Transact-SQL).
  4. Specify the destination for the captured event data using xp_trace_setqueuedestination.

To set trace definition defaults

To set trace display defaults

To create a trace

    

To create a trace using the Create Trace Wizard

To add or remove events from a trace

    

To modify data columns

    

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.