locked
SSMS Cannot execute as database principal (Microsoft SQL Server, Error: 15517) RRS feed

  • Question

  • Hello,

    I have an .mdf file that I tried to attach in SSMS.  I am using (LocalDB)\MSSQLLocalDB (SQL Server 12.0.2569) The attach process seems to have completed successfully but when I want to make any changes at all I get the message:

    "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)"

    I can see the database diagram in VS when I create and Entity Framework Model but I am unable to perform any functions in SSMS like being able to establish relationships and the like.

    I would appreciate some guidance on this.

    Thank you.

    Sunday, January 1, 2017 5:37 PM

Answers

  • Is this what you are looking for?

    https://msdn.microsoft.com/en-us/library/ms178630.aspx

    • Marked as answer by Geol4549 Saturday, November 17, 2018 6:35 PM
    Tuesday, January 3, 2017 2:22 AM
  • Thank you, that worked.
    • Marked as answer by Geol4549 Wednesday, January 24, 2018 3:47 PM
    Wednesday, January 24, 2018 3:10 PM

All replies

  • Try this:

    use [databasename]

    GO

    EXEC sp_changedbowner 'sa' 

    GO

    • Proposed as answer by AV111 Saturday, November 17, 2018 5:43 AM
    Sunday, January 1, 2017 10:38 PM
  • EXEC sp_changedbowner 'sa' 

    Alternatively:

    ALTER AUTHORIZATION ON DATABASE::YourDatabase TO sa;


    Dan Guzman, Data Platform MVP, http://www.dbdelta.com

    Monday, January 2, 2017 12:10 AM
  • Do Graphically.

    Database right click-->properties-->files-->select database owner-->select [sa]-- ok


    Please Mark it as Answered if it answered your question OR mark it as Helpful if it help you to solve your problem.

    • Proposed as answer by Flem100DK Wednesday, January 24, 2018 3:10 PM
    Monday, January 2, 2017 12:43 AM
  • Thank you all very much.  That is very helpful.
    • Marked as answer by Geol4549 Monday, January 2, 2017 2:48 PM
    • Unmarked as answer by Geol4549 Monday, January 2, 2017 3:00 PM
    Monday, January 2, 2017 2:48 PM
  • Finally,  where can I find more information on sp_ command editor?

    Thanks

    Monday, January 2, 2017 3:01 PM
  • Hi Geol4549,

    I’m not quite following here, could you please elaborate more? Are you looking for a list of system stored procedures? If so, please refer to this link.

    If you have any other questions, please let me know.

    Regards,
    Lin

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 3, 2017 2:08 AM
  • Is this what you are looking for?

    https://msdn.microsoft.com/en-us/library/ms178630.aspx

    • Marked as answer by Geol4549 Saturday, November 17, 2018 6:35 PM
    Tuesday, January 3, 2017 2:22 AM
  • Thank you, that worked.
    • Marked as answer by Geol4549 Wednesday, January 24, 2018 3:47 PM
    Wednesday, January 24, 2018 3:10 PM
  • Thank you
    Monday, June 18, 2018 1:06 AM
  • Thanks a lot! It worked.
    Friday, June 29, 2018 11:14 AM
  • thank you very much
    Saturday, November 17, 2018 4:57 AM