SQL Server Profiler offers predefined trace templates that allow you to easily configure the event classes that you will most likely need for specific traces. The Tuning Template captures information about Stored Procedures and Transact-SQL batch execution. Use to produce trace output that Database Engine Tuning Advisor can use as a workload to tune databases.
This example is designed for an interactive tracing session and requires the following:
- SQL Server Profiler
- SQL Server Database Engine Tuning Advisor
Edit The Tuning Template
In this example we will edit the existing Tuning Template and save it under another Template name to preserve the original settings.
- Open SQL Server Profiler and select Edit > Templates > Edit Template.
- Click the Events Selection tab.
- Check the Show All Events checkbox.
- Under TSQL add the SQL StmtCompleted option. Check all associated columns.
- Uncheck the Show All Events checkbox.
- Under Errors and Warnings select the Exception and User Error Message events
- Check the Show All Columns checkbox and select the columns shown in the graphic.
- Uncheck the Show All Columns checkbox.
- Click Save As.
Filtering Tracing Messages
Tracing can produce a large number of messages. Apply filters whenever possible to reduce the number of messages, such as by Database Name.
If the Database Name is not available, filter by Database ID. Use the query below to list Database ID and Name. SELECT [name],[dbid] FROM [master].[dbo].[sysdatabases] ORDER BY [name]
Configure And Run The Trace
- In SQL Server Profiler select Edit > New Trace.
- Select the correct Template from the drop-down in the Use the template field.
- Click the Run button.
- After a period of time or when an event has occurred, stop the trace and review the results.
Example - Capturing A GP eConnect Stored Procedure
NOTE: The SQL can be copied into SQL Server for testing purposes.
You may want to add an additional filter in this case specifying the eConnect Stored Procedure name. The eConnect Stored Procedure name can be found in the Scribe Trace file by searching for stored a procedure.