Sqlserver this database does not have a valid owner error Solution

Source: Internet
Author: User

One day, when I debugged the program, I suddenly found that the following error was returned when I wanted to add a relational table after I attached the database:
The database does not have a valid owner, so you cannot install the database relational diagram support object. To continue, first set the database owner to a valid login name using the "file" page or the Alter AUTHORIZATION statement in the "database properties" dialog box, and then add a database relational diagram support object.
The first method does not work, and the file owner is sa. After searching for a long time in csdn, a comrade gave the second solution using ssms. Run the following command in SSMS:
Alter authorization on database: mydbname TO sa
Modify mydbname to the actual database name, and set the owner to sa.
After some effort, I did not find ssms [Haha, I successfully executed the query in the new query, but it did not solve the problem], ah. This is also ruined. I have a new idea in mind.
Imagine the troubles of the grid system, followed by Baidu. This solution was found in a forum:
The solution is as follows:
1. Set the compatibility level to 90 (2005 to 90) (2000 to 80)
USE [master]
GO
EXEC dbo. sp_dbcmptlevel @ dbname = 'database name', @ new_cmptlevel = 90
GO
[This command has been executed: "DBCC has been executed. If DBCC outputs an error message, contact the system administrator ", report "this database lacks one or more support objects required to use the database relationship diagram, whether to create", select "yes", the problem is resolved]
Alternatively, right-click the database you restored, choose Properties> Options> Compatibility Level, select sqlserver2005 (90), and click OK. (Well, I used this solution. Haha, a little pleasure)
When you expand the "database relationship diagram" node under the database, you will be prompted, "This database lacks one or more support objects required to use the database relationship diagram, whether to create ", select "yes.
2. If the problem persists after performing the above operations, continue as follows:
Select your database, select "security"-> "user", and select dbo to open the attribute page. If the logon name is empty, create a new query and
Use [your database name]
EXEC sp_changedbowner 'sa'
After the execution is successful, select the "database relationship diagram" node and prompt "this database lacks one or more support objects required to use the database relationship diagram, whether to create ", select "yes. You can see the previously created graph.
Haha. It took a lot of effort to complete, huh, huh. The reason may be that the original database was created using SQL server2000. After attaching the database to 2005, the parsing will fail.

Related Article

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.