Skip to main content

Query to Set MSSQL Database Owner

This resolves an error encountered disabling the ability to view database properties via SQL Management Studio: "Property Owner is not available for Database '[DB_name]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Smo)" And a related error: "The database owner SID recorded in the master database differs from the database owner SID recorded in database 'XYZ'. You should correct this situation by resetting the owner of database 'XYZ' using the ALTER AUTHORIZATION statement."

Where !DBNAME= database name, and the default System Administrator remains 'sa': 

EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false