MS SQL Server – Service Broker Errors ( 15517, 33009)

Once again, the Event Viewer on one of MS SQL Server boxes was getting clobbered with entries such as

An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal “dbo” does not exist, this type of principal cannot be impersonated, or you do not have permission.

Tried fixing it with:


use  [dbName];
exec [dbName].dbo.sp_changedbowner 'sa'

But, we started seeing these other errors:


An exception occurred while enqueueing a message in the target queue. Error: 33009, State: 2. 
The database owner SID recorded in the master database differs from the database owner SID recorded in database 'MyOnlyDB'. 
You should correct this situation by resetting the owner of database 'MyOnlyDB' using the ALTER AUTHORIZATION statement.

proc [profiler].[SqlQueryNotificationStoredProcedure-bd5b40d2-f34d-4ee1-9373-eceb4b8bd492] running on queue MyOnlyProd.profiler.SqlQueryNotificationService-bd5b40d2-f34d-4ee1-9373-eceb4b8bd492 output the following:  'The database owner SID recorded in the master database differs from the database owner SID recorded in database 'MyOnlyProd'. 
You should correct this situation by resetting the owner of database 'MyOnlyProd' using the ALTER AUTHORIZATION statement.'

We finally corrected by running:


alter database [MyOnlyProd] SET TRUSTWORTHY ON;

ALTER AUTHORIZATION ON DATABASE::[MyOnlyProd] to sa;

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s