SQL Server workaround for this database without a valid owner error

Source: Internet
Author: User
Tags continue execution sql query valid
One day, when debugging a program, suddenly found that after attaching a database, want to add a relational table, the result came out the following error:
The database diagram support object cannot be installed because the database does not have a valid owner. To continue, first set the database owner to a valid login using the file page of the Database Properties dialog box or the ALTER AUTHORIZATION statement, and then add the database diagram support object.
Changing in the first way is not possible, and the owner of the file is also SA. In CSDN for a long time, a comrade gave a second solution, the use of ssms. Run the following command specifically in SSMS:
Alter AUTHORIZATION on Database::mydbname to SA
By modifying the mydbname to the actual database name, you can set the owner to SA.
After some efforts also did not find ssms[oh, I was in the new query execution success, but did not solve the problem], hey. This is a bust, too. There is the idea of a new grid system in mind.
Imagine the trouble with the grid system, followed by Baidu. The solution was found in a forum:
The workaround is as follows:
1, set the compatibility level is 90 (2005 is 90) (2000 is 80)
Use [master]
Go
EXEC dbo.sp_dbcmptlevel @dbname = ' database name ', @new_cmptlevel =90
Go
[This command completes:] The DBCC execution is complete. If DBCC outputs an error message, contact your system administrator. "No matter what it is, then click on" Database Diagram ", the report" This database is missing one or more supporting objects to use the database diagram, whether to create ", select" Yes ", problem solved.
Or select the database you restored, right-click, select attribute-> option-> compatibility level, choose sqlserver2005 (90) and then OK. (Oh, I just use this method to solve.) Oh, a little happy.
At this point, you will be prompted to expand the database Diagram node under the database, "This database is missing one or more supporting objects that are required to use the database diagram, create", and select Yes.
2, through the above methods of operation, if the problem persists, in the following ways to continue
Select your database and select "Security"-> "user", select dbo, open the Properties page, if the login name is empty, create a new query, and then
Use [your database name]
EXEC sp_changedbowner ' sa '
After successful execution, you will then select the Database Diagram node and prompt "This database is missing one or more supporting objects required to use the database diagram, create", and select Yes. You can see the original diagram.
Oh. It took a lot of effort to finish, hehe. The reason may be that the original database was created using SQL server2000. When you attach the database to 2005, you cannot parse it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.