--check whether service broker is enabled
SELECT is_broker_enabled FROM sys.databases WHERE name = 'rextester'
--enable broker
ALTER DATABASE rextester SET ENABLE_BROKER
--disable broker
ALTER DATABASE rextester SET DISABLE_BROKER
--in case of 'The Service Broker in database "rextester" cannot be enabled because there is already an enabled Service Broker with the same ID.'
ALTER DATABASE rextester SET NEW_BROKER
Error(s), warning(s):
[sys].[databases] and [sys].[sysdatabases] are not allowed to be used in code due to security reasons