I restored a DB but it does not allow me to create a Database Diagram

Juan Dent 236 Reputation points
2022-07-16T16:26:57.523+00:00

I am using SQL Server Management Studio (version 18.12.1) and just restored a database not created by me, and when I try to create a DB diagram I get an error like this:

Cannot execute as thee database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission, (Microsoft SqlServer Error: 15517)

The database is Microsoft SQL Server Express version 15.0.4153.1

If I create a database from scratch I can create db diagrams!!! But not with these other databases... what can I do to fix this?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,492 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 119.8K Reputation points MVP
    2022-07-16T18:26:07.343+00:00

    This is due to that the SID for the dbo inside the database does not match the owner_sid in sys.databases.

    A simple way out is to change the database owner:

       ALTER AUTHORIZATION ON DATABASE::YourDB TO YourDomain\YourUser  
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.