Changing the SQL Server database owner SID after a restore from backup with the ALTER AUTHORIZATION statement
Posted: (EET/GMT+2)
Sometimes, you need to perform database level operations on a database, but you will get an error message saying that the owner SID is incorrect. This can happen for example when you restore a database backup from another SQL Server system.
The error message is the following:
The database owner SID recorded in the master database differs from the database owner SID recorded in database 'MyDatabase'. You should correct this situation by resetting the owner of database 'MyDatabase' using the ALTER AUTHORIZATION statement.
To solve this, simply run a single ALTER AUTHORIZATION statement. For example, in case of a domain account, you could do this:
ALTER AUTHORIZATION ON DATABASE::[MyDatabaseName] TO [SOMEDOMAIN\some.user]
This solves the problem.