In this post I will cover to enable the service broker id and solution of some error related to this.
With the help of below query we can see what is the service broker id of database and whether it is enabled or not.
With the help of below query we can see what is the service broker id of database and whether it is enabled or not.
SELECT
is_broker_enabled AS IsServiceBrokerEnabled,
service_broker_guid AS ServiceBrokerGUID,
name AS DatabaseName,
database_id AS DatabaseId
FROM sys.databases
In below screen shot highlighted row shows that service borker is not enabled for the database TestDatabase.
We can enable the service broker queue with the help of below query
ALTER DATABASE Database_Name SET
ENABLE_BROKER;
If you have database which is huge in size then above query may take time. In that case you can use the below query.
ALTER DATABASE Database_Name SET
ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
Now, some time we are getting the error
Msg
9772, Level 16, State 1, Line 1
The Service Broker in database "Database_Name" cannot be enabled because there is already an enabled Service Broker with the same ID.
The Service Broker in database "Database_Name" cannot be enabled because there is already an enabled Service Broker with the same ID.
This error is coming because there is already one database which is having the same service broker id and system is trying to enable another database with the same service broker id. The solution of this error is to generate the new service broker id for the database. This we can achieve with below query
ALTER DATABASE Database_Name SET
NEW_BROKER;
If you have database which is huge in size then above query may take time. In that case you can use the below query.
ALTER DATABASE [Database_name] SET
NEW_BROKER WITH
ROLLBACK IMMEDIATE;
Thx,
RS
No comments:
Post a Comment