Sql 2005 Database diagram support objects cannot be installed because this database does not have a valid owner


Problem

After restoring DB in SQL Server 2005 db most of the time I get the following error:

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.

Solution
This was not new to me and I always used to take the following steps to solve it:

1. Right Click on your database, choose properties
2. Goto the Options Page
3. In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
4. Goto the Files Page
5. Enter "sa" in the owner textbox.
6. Hit OK

But for some reason today the above steps did not work.... After googling for a while I quickly found
the following suggestion which worked just fine for me....

EXEC sp_dbcmptlevel 'yourDB', '90';
go
ALTER AUTHORIZATION ON DATABASE::yourDB TO "yourLogin"
go
use [yourDB]
go
EXECUTE AS USER = N'dbo' REVERT
go
posted @ 2009-08-18 16:19  helloworld22  阅读(421)  评论(2编辑  收藏  举报