I have restore a database from MSSQL 2000 to MSSQL 2005. When i try to open the database diagram, error message below pop up:
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.
ALTER AUTHORIZATION ON DATABASE: Database_name TO valid_login
I use SSMS to solve my problem.
In SQL Server Management Studio do the following:
- Right Click on your database, choose properties
- Go to the Options
- In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
- Go to Files
- Type "sa" in the owner textbox
- Click OK
This solve my problem.
Alternatively, we can solve it using TSQL:
- My database name: avlDB
- MY Login: sa
EXEC sp_dbcmptlevel 'avlDB', '90';
GO
ALTER AUTHORIZATION ON DATABASE::avlDB TO "sa"
GO
USE [avlDB]
GO
EXECUTE AS USER = N'dbo' REVERT
GO