Problem:
During the development process, the operating system was out of the question and decided to reload the system. However, the database files in SQL Server are not separated and the system is directly in the grid. Attaching the database file to the new system database is normal, but there is a problem when opening the database diagram, as shown in:
Solution: (Three kinds)
1, right-click your database name → properties → file → owner →sa; (This method is found on the Internet and may not be successful)
2, set compatibility level of 90 (2005 is 90,2000 to 80)
(1) Code:
Use [master]
GO
EXEC dbo.sp_dbcmptlevel @dbname = ' database name ', @new_cmptlevel =90
GO
(2) Pinch mouse
Or select the database you restored, right-click, select Properties-----compatibility level, choose sqlserver2005 (90) and then OK. At this point, when you expand the database Diagram node under the database, there is a hint, "This database is missing one or more of the supporting objects required to use the database diagram, whether it is created, or" Yes "is selected.
3. Select your database, then select security → user → select dbo, open the property page, if the login name is empty, create a new query, and then
Use [your database name]
EXEC sp_changedbowner ' sa '
Three solutions for SQL Server databases without valid owners