When you create or edit a trace, you can save the trace to replay it later. SQL Profiler features a multithreaded playback engine that can simulate user connections and SQL Server Authentication, allowing the user to reproduce the activity captured in the trace. Therefore, replay is useful when troubleshooting an application or process problem. When you have identified the problem and implemented corrections, run the trace that found the potential problem against the corrected application or process, then replay the original trace to compare results.
Trace replay supports debugging using break points and run-to-cursor, which especially improves the analysis of long scripts. For more information, see Single-Stepping Traces.
In addition to any other event classes you want to monitor, the following event classes must be captured in a trace to allow the trace to be replayed:
In addition to any other data columns you want to capture, the following data columns must be captured in a trace to allow the trace to be replayed:
Note Use the sample trace template SQLProfilerTSQL_Replay for traces capturing data for replay.
In order to replay a trace against a computer running Microsoft® SQL Server™ (the target), other than the computer originally traced (the source):
Replaying events associated with missing or incorrect logins will result in replay errors, but the replay operation will continue.
In order to replay a trace against an instance of SQL Server (the target), other than the computer originally traced (the source), either:
Before replaying a captured trace, you can specify:
The server is the name of the instance of SQL Server against which you want to replay the trace. The server must adhere to the replay requirements previously mentioned.
The output file contains the result of replaying the trace for later viewing. If Progress is selected, then the output file can be also replayed at a later time. By default, SQL Profiler displays only the results of replaying the trace to the screen.
Specify to replay events in the order they were traced. This allows you to use debugging methods such as stepping through each trace.
Specify to replay events using multiple threads. This optimizes performance, but debugging is disabled.
Specify to display the results of the replay. This is the default option. If the trace you are replaying is very large, you may want to disable this to save disk space.
Note For best replay performance, it is recommended that you select to replay events using multiple threads, and do not select to display the replay results.
SQL Profiler cannot replay traces:
Additionally, SQL Profiler cannot replay SQL Trace .log files that contain SQL Server 6.5 server-side cursor statements (sp_cursor).
Unexpected results or replay errors can occur when replaying a trace containing the Sessions event classes (Connect, Disconnect, and Existing Connection) if the Binary Data data column is not also captured in the trace. The Binary Data data column, for the Session event classes, contains information required to set ANSI nulls, ANSI padding, cursor close on commit, concat null yields null, and quoted identifier session settings. For more information, see SET.
When replaying a trace containing concurrent connections, SQL Profiler creates a thread for each connection. Therefore, system performance of the computer replaying the trace can be affected if the trace contains many concurrent connections. To reduce the effect on system performance, filter the trace by specifying a value(s) for the Application Name, SQL User Name, or another data column captured in the trace, to focus the trace on only those events you need to monitor.
Note If you do not use the provided replay template (SQLProfilerTSQL-Replay), you may encounter difficulties capturing the current database context. For more information, see Troubleshooting SQL Profiler.
To replay a trace table