Edit

Share via


DROP EVENT SESSION (Transact-SQL)

Applies to: SQL Server Azure SQL Managed Instance

Drops an event session.

Transact-SQL syntax conventions

Syntax

DROP EVENT SESSION event_session_name
ON { SERVER | DATABASE }

Arguments

event_session_name

The name of an existing event session.

Remarks

When you drop an event session, all configuration information, such as targets and session parameters, is completely removed.

Permissions

SQL Server and Azure SQL Managed Instance require the DROP ANY EVENT SESSION (introduced in SQL Server 2022), or ALTER ANY EVENT SESSION permission.

Azure SQL Database requires the DROP ANY DATABASE EVENT SESSION permission in the database.

Tip

SQL Server 2022 introduced more granular permissions for Extended Events. For more information, see Blog: New granular permissions for SQL Server 2022 and Azure SQL to improve adherence with PoLP.

Examples

The following example shows how to drop an event session. To use this example with database event sessions, replace ON SERVER with ON DATABASE.

DROP EVENT SESSION test_session ON SERVER;