sql-server add tag
liquid (imported from SE)
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?
Top Answer
Paul White
You need to give the database a valid owner. Use the [`ALTER AUTHORIZATION`][1] command to do this:

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

[Related Knowledge Base article][2]

Note the [sp_changedbowner][3] system stored procedure has been deprecated in favour of `ALTER AUTHORIZATION`.


  [1]: https://msdn.microsoft.com/en-us/library/ms187359(v=sql.105).aspx
  [2]: https://support.microsoft.com/en-us/kb/913423
  [3]: https://technet.microsoft.com/en-us/library/ms178630(v=sql.105).aspx

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.