SQL SERVER – FIX: Database Diagram Error 15517 – Cannot Execute as the Database Principal Because the Principal ‘dbo’ Does Not Exist

Today’s blog post is directly inspired by the conversation I had during my Comprehensive Database Performance Health Check. During the consulting engagement, one of the developers reported below error in the database while trying to open a database diagram.

Cannot execute as the database principal because the principal ‘dbo’ does not exist, this type of principal cannot be impersonated, or you do not have permission. (Microsoft SQL Server, Error: 15517)

As per message, it is clear that something is not right with database principal dbo. I asked history about it and learned that this database was restored from some other server. I was able to run some queries and find the issue.

To verify if you are running into the same issue, you can run below query to find who is mapped to “dbo” in the database. My sample database name is AdventureWorks, so please change accordingly.

USE AdventureWorks
SELECT SUSER_SNAME(sid), * from sys.database_principals

If the first column shows as NULL then below fix would work.


This was just a different variation of error which I have explained in my earlier blog. SQL SERVER – ERROR: FIX – Database diagram support objects cannot be installed

We went ahead and changed the owner of the database in the UI (Properties > Files tab)

SQL SERVER - FIX: Database Diagram Error 15517 - Cannot Execute as the Database Principal Because the Principal 'dbo' Does Not Exist db-diagram-err-01

Here is the equivalent command.

USE [AdventureWorks]

After doing this, the issue was resolved, and they were able to use this feature?

How many of you use this old feature? Truly speaking, I have not seen many using it in production.

Reference: Pinal Dave (https://blog.sqlauthority.com)

, , , ,
Previous Post
SQL SERVER – FIX: The specified instance of SQL Server is hosted by a system that is not a Windows Server Failover Cluster(WSFC) Node.
Next Post
SQL SERVER – Unable to Set Cloud Witness. Error: An Existing Connection Was Forcibly Closed by The Remote Host

Related Posts

30 Comments. Leave new

  • Wow! This is fantastic! And super simple!

  • what if first column come with some data??

  • Thank you for it.

  • Mohammad Reza
    April 17, 2021 2:31 am

    Hi Pinal
    Your solutions are really helpful
    Thank you

  • I tried it for mines and it still didnt work, instead this was the message that I had gotten back.

    “Database ‘AdventureWorks’ does not exist. Make sure that the name is entered correctly.
    Msg 15151, Level 16, State 1, Line 3
    Cannot find the database ‘AdventureWorks’, because it does not exist or you do not have permission.”

    Is there any other fixes I could try. I even tried getting it back form the site again but that didn’t help.

  • Mukelabai Mukelabai
    May 24, 2021 8:02 pm

    It didn;t work for me but what I noticed that I had this problem when I logged into SQL server using windows authentication. So I logged in using sql server authentication and the problem was resolved

  • did you check to see if your database was called AdventureWorks? You need to put the correct database name here

  • Works great for me, thanks!

  • Thank you so much!!!



Leave a Reply