0

When I try to send email using:

EXEC sp_send_dbmail

I get this error:

Service Broker message delivery is not enabled in this database. Use the ALTER DATABASE statement to enable Service Broker message delivery.

So I am trying to execute:

USE master;
GO
ALTER DATABASE [MyDatabaseName] SET ENABLE_BROKER;
GO

But the above statement is running infinitely without error message or timeout.

When I run below statement:

select name, is_broker_enabled from sys.databases

I can see that service broker is still disabled.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3057544
  • 807
  • 9
  • 22
  • 2
    That command requires a lock on the DB, so if you've got an active database, it's just going to wait until it can execute the ALTER. An old, but similar question - https://stackoverflow.com/questions/1094202/enable-sql-server-broker-taking-too-long – Craig Apr 03 '23 at 05:20
  • thanks Craig, adding: ' with rollback immediate;' did the job. – user3057544 Apr 03 '23 at 07:45

0 Answers0