Wednesday, 11 August 2010

After restoring a database the owner has changed.

Question:
I restored a db from my production environment.
After that step certain things became strange. It was for example now impossible to install diagram support.
I always receive this error.




TITLE: Microsoft SQL Server Management Studio 
------------------------------ 
Database diagram support objects cannot be installed because this database 
does not have a valid owner. To continue, first use the Files page of the 
Database Properties dialog box or the ALTER AUTHORIZATION statement to set 
the database owner to a valid login, then add the database diagram support 
objects. 
------------------------------ 

The compatbility level of my database is already set to 2005 (90). So, changing it, will not help.

Answer:
What you have to know is, that when you restore a database the user running the restore command becomes the owner of the database.
You must rechange the owner of the db.

sp_changedbowner 'sa' 


Links

http://searchsqlserver.techtarget.com/tip/Restoring-a-database-from-another-SQL-Server

No comments: