Sunday, August 7, 2011

Enabling Service Broker on MSDB

Sometimes SQL Server jobs will be failed due to the following issue:

Msg 14650, Level 16, State 1, Procedure sp_send_dbmail, Line 72
Service Broker message delivery is not enabled in this database. Use the ALTER DATABASE statement to enable Service Broker message delivery.

Solution
Enable Service Broker on MSDB …
To check Service Broker is enabled on MSDB, please execute the given query:
select is_broker_enabled,* from sys.databases where name = 'MSDB'

If the output value of “is_broker_enabled” is 0 -> Service Broker NOT enabled
Note: A value of 0 indicates that Service Broker message delivery is not activated in the MSDB database

If the output value of is_broker_enabled is 1 -> Service Broker IS enabled

To enable the Service Broker on MSDB database is as follows:

1) Connect to SQL Server
2) Stop the SQL Agent Services
3) Run the query "ALTER DATABASE MSDB SET ENABLE_BROKER"
4) Check the service broker is enabled or not by executing the below query:
4.1) select is_broker_enabled from sys.databases where name = 'MSDB'
4.2) The output value “1” means service broker is successfully enabled
5) Start the SQL Agent Services

Reason to stop SQL Agent services: Enabling Service Broker is not allowed when the database is in USE. Obviously SQL Agent will use MSDB database.

After the execution of the above, please exeute the below scripts to confirm that we are receving mails:

EXEC msdb.dbo.sp_send_dbmail
@recipients = user_name@mail.com',
@body = 'TEST.',
@subject = 'TEST' ;

9 comments:

  1. thank you sir. its worked for me. :)

    BR
    Kiran Prasad

    ReplyDelete
  2. Thank you. Even if you stop SQL Agent it is possible that another call may be even if sleeping , need to be terminated forst.
    But that thanks for this. Why does a restore a DB causes the Service Broker enabled to go off ?

    ReplyDelete
  3. Can we use the same method in cluster environmnet also?

    ReplyDelete
  4. This will also work: alter database msdb set enable_broker with rollback immediate;

    ReplyDelete
  5. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Best south african brokers

    ReplyDelete
  6. The FED, presently been triggered to cut rates as well as boost the economy has been responding on Friday. Chairman Powell has kept in mind that the FED will make use of all the devices at its disposal to guarantee economic stability. This some analysts believe is a sign of coming rate cuts. Auto crypto bot

    ReplyDelete
  7. Bruc Bond endeavor to lead the financial sector with sustainability, customizable product offering, and open communication. At Bruc Bond we aim to make 21st century banking straightforward, simple, and transparent.

    ReplyDelete
  8. Hallmark examples of FinTech in our life are Mobile Payment applications, Cryptocurrency and Blockchain like Bitcoin and Gemini. In the future the series of FinTech solutions is anticipated to transform the marketplace a lot more with AI as well as artificial intelligence as well as will make FinTech products an essential part of our digitalized life.

    Bruc Bond executive Eyal Nachum

    ReplyDelete