Megosztás a következőn keresztül:


Using SQL Server Extended Events

SQL Server Extended Events provide Data Definition Language (DDL) statements for creating and modifying an Extended Events session. In addition, there are dynamic management views and catalog views that you can use to obtain session data and metadata.

You can use Transact-SQL statements to run the views that are provided to obtain the information that you need from every extended events session that you create.

You can use SQL Server Management Studio to create and execute the code samples that are provided. For more information, see Using Object Explorer.

DDL Statements

Use the DDL statements described in the following table to create, change, and drop an Extended Events session.

Name

Description

CREATE EVENT SESSION (Transact-SQL)

Creates an extended event session object that identifies the source of the events, the event session targets, and the event session parameters.

ALTER EVENT SESSION (Transact-SQL)

Starts or stops an event session or changes an event session configuration.

DROP EVENT SESSION (Transact-SQL)

Drops an event session.

Catalog Views

Use the catalog views described in the following table to obtain the metadata that is created when you create an event session.

Name

Description

sys.server_event_sessions (Transact-SQL)

Lists all event session definitions.

sys.server_event_session_actions (Transact-SQL)

Returns a row for each action on each event of an event session.

sys.server_event_session_events (Transact-SQL)

Returns a row for each event in an event session.

sys.server_event_session_fields (Transact-SQL)

Returns a row for each customizable column that was explicitly set on events and targets.

sys.server_event_session_targets (Transact-SQL)

Returns a row for each event target for an event session.

Dynamic Management Views

You use the dynamic management views described in the following table to obtain session metadata and session data. The metadata is obtained from the catalog views, and the session data is created when you start and run an event session.

Note

  These views do not contain session data until a session starts.

Name

Description

sys.dm_os_dispatcher_pools (Transact-SQL)

Returns information about session dispatcher pools.

sys.dm_xe_objects (Transact-SQL)

Returns a row for each object that is exposed by an event package.

sys.dm_xe_object_columns (Transact-SQL)

Returns the schema information for all the objects.

sys.dm_xe_packages (Transact-SQL)

Lists all the packages registered with the extended events engine.

sys.dm_xe_sessions (Transact-SQL)

Returns information about an active extended events session.

sys.dm_xe_session_targets (Transact-SQL)

Returns information about session targets.

sys.dm_xe_session_events (Transact-SQL)

Returns information about session events.

sys.dm_xe_session_event_actions (Transact-SQL)

Returns information about event session actions.

sys.dm_xe_map_values (Transact-SQL)

Provides a mapping of internal numeric keys to human-readable text.

sys.dm_xe_session_object_columns (Transact-SQL)

Shows the configuration values for objects that are bound to a session.