33

I restored a backup of a database from SQL Server 2008 R2 to SQL Server 2012.

When I try to access a particular page of my application, I get this error:

Cannot execute as the database principal because the principal "dbo" does not exist

It works with my 2008 R2 project perfectly. How can I resolve this issue?

Paul White
  • 83,961
  • 28
  • 402
  • 634
Liquid
  • 433
  • 1
  • 4
  • 5
  • 1
    The solution that worked for me was ALTER AUTHORIZATION ON DATABASE::[<dbname>] TO [sa]; as noted on the question that is stated above as the original of this duplicate. – isapir Dec 09 '16 at 21:07

1 Answers1

48

You need to give the database a valid owner. Use the ALTER AUTHORIZATION command to do this:

ALTER AUTHORIZATION 
ON DATABASE::[DatabaseName]
TO [A Suitable Login];

Related Knowledge Base article

Note the sp_changedbowner system stored procedure has been deprecated in favour of ALTER AUTHORIZATION.

Paul White
  • 83,961
  • 28
  • 402
  • 634