ERROR:
The database owner SID recorded in the master database differs from the database owner SID recorded in database ‘database_name’. You should correct this situation by resetting the owner of database ‘database_name’ using the ALTER AUTHORIZATION statement.
EXPLANATION:
When a user wanted to run a SP in the system, he said he had encountered such an error. The TRUSTWORTHY feature was turned on in the database. Because I’ve already encountered this problem before, I knew that the problem was caused by the database owner.
SOLUTION:
The problem is solved when you set the database owner to “sa” with the following code:
1 2 3 4 | USE [database_name] GO EXEC sp_changedbowner 'sa' GO |
You can do this with the above script, but the microsfot announces that sp_changedbowner will be removed. Instead, it recommends using the following script.
1 | ALTER AUTHORIZATION ON DATABASE::MyDatabase TO sa; |