Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
SQL database in Microsoft Fabric Preview
Learn how the SQL Trace events map to Extended Events events and actions. You can collect event data that is equivalent to SQL Trace event classes and columns.
You can use the following procedure to view the Extended Events events and actions that are equivalent to each SQL Trace event and its associated columns.
To run T-SQL commands, use SQL Server Management Studio (SSMS), the MSSQL extension for Visual Studio Code, sqlcmd, or your favorite T-SQL querying tool.
View the Extended Events equivalents to SQL Trace events using Query Editor
From a Query Editor in SQL Server Management Studio, run the following query:
SELECT DISTINCT tb.trace_event_id, te.name AS 'Event Class', em.package_name AS 'Package', em.xe_event_name AS 'XEvent Name', tb.trace_column_id, tc.name AS 'SQL Trace Column', am.xe_action_name AS 'Extended Events action' FROM sys.trace_events AS te LEFT JOIN sys.trace_xe_event_map AS em ON te.trace_event_id = em.trace_event_id LEFT JOIN sys.trace_event_bindings AS tb ON em.trace_event_id = tb.trace_event_id LEFT JOIN sys.trace_columns AS tc ON tb.trace_column_id = tc.trace_column_id LEFT JOIN sys.trace_xe_action_map AS am ON tc.trace_column_id = am.trace_column_id ORDER BY te.name, tc.name;
Note:
If all columns return
NULL
except for theEvent Class
column, the event class was not migrated from SQL Trace.If only the value in the
Extended Events action
column isNULL
, either of the following conditions is true:The
SQL Trace column
maps to one of the data fields that is associated with the Extended Events event.Each Extended Events event has a default set of data fields that are automatically included in the result set.
The
action
column does not have a meaningful Extended Events equivalent. An example is theEventClass
column in SQL Trace. This column is not needed in Extended Events because the event name serves the same purpose.
Extended Events uses a single event to replace user configurable SQL Trace event classes (
UserConfigurable:1
throughUserConfigurable:9
). The event is nameduser_event
. This event is raised by usingsp_trace_generateevent
, which is the same stored procedure that is used by SQL Trace. Theuser_event
event is returned regardless of which event ID is passed to the stored procedure. However, anevent_id
field is returned as part of the event data, which you can use to build a predicate based on the event ID. For example, if you useUserConfigurable:0
(event ID = 82) in the code, you can add theuser_event
event to the session, and specify a predicate ofevent_id = 82
. Therefore, you do not have to change the code because thesp_trace_generateevent
stored procedure generates the Extended Eventsuser_event
event, and the equivalent SQL Trace event class.