出错信息如下:
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.
我是用windows帐户登陆的。(试了下sa登陆,结果一样)
解决方法:
1. 右键点击数据库,选“properties ”
2. 点选左侧“Options”
3. 在'Compatibility Level' 选 'SQL Server 2005(90)'
4. 点选左侧“Files”
5. 在owner里填入 'sa'
6. OK
至此,Diagrams目录可以使用了。
=======Updated at 2006-2-16
问题原因及解决办法!
不光是从sql2000升级到sql2005,在2台装sql2005的机器间备份/恢复后,问题同样会出现。
微软新闻组的Steven Twitchell 给出问题答案,并说在sp1中应该解决。
When the database does not have a valid owner, the database dialog displays the owner as the logged in user. (This issue will be fixed in SP1.)
The "no valid owner" issue usually comes up when databases are owned by SQL-authentication logins and are upgraded, detached/attached to another server, or restored from backup to another server. The SID (a large number) doesn't match any existing login on the new server, so the owner name remains whatever it was on the old server, but it is marked invalid. Explicitly setting the owner to a valid principal on the server solves the problem.
There is also a known issue when the UI tries to install the database support objects on databases where the compatibility level is set to 80 (SQL Server 2000). The installation fails and the UI incorrectly reports that the database has no valid owner. Setting compatibility level to 90 (SQL Server 2005) before installing the diagram support objects solves this problem. (This issue will also be fixed in SP1.)
目前我总结的解决方法:
因为备份机器上帐号的SID和恢复机器上的SID不同(即使名字完全一样),所以,最简单的办法是将此数据库的db_owner随便换个,点击Diagrams(关系图)使之可用后,再改回db_owner 。