Edit

Share via


How to: Deactivate Service Broker message delivery in databases (Transact-SQL)

Applies to: SQL Server Azure SQL Managed Instance

When message delivery isn't active, messages remain in the transmission queue. To determine whether Service Broker is active for a database, check the is_broker_enabled column of the sys.databases catalog view.

Note

Deactivating Service Broker prevents messages from being sent from or delivered to the database. However, this doesn't prevent messages from arriving in the instance. To prevent messages from arriving in the instance, you must remove or stop the Service Broker endpoint.

Deactivate Service Broker in a database

  • Alter the database to set the DISABLE_BROKER option.

Examples

Note

The code samples in this article were tested using the AdventureWorks2025 sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page.

USE master;
GO

ALTER DATABASE AdventureWorks2008R2
    SET DISABLE_BROKER;
GO