Friday, July 13, 2012

Cannot alter the user 'dbo'. (Microsoft SQL Server, Error: 15150)


Some times we may get the below error while updating the login from dbo to some other login from user mapping window.

1. I have database which is mapped with dbo login and dbo schema.
2. I tried to update the database with app_user login, then it displays that error message.

To fix the issue we need to change the default owner to 'sa' and then tried to update the login.

Use database_name
sp_changedbowner 'sa'

It may cause because dbo is mapped with some other login, then we need to change the dbo login name to 'sa', it is because the sa login is reffered as dbo and it will exists in all the databases. So we should not modify the dbo login to any other login except 'sa'.

11 comments:

  1. Great, this worked for me. Thanks !

    ReplyDelete
  2. thanks a loooooot it works for me

    ReplyDelete
  3. Great, this worked for me. Thanks !

    ReplyDelete
  4. Worked like a charm. In my case, though the owner shows sa, the dbo user is mapped to some other login. However, when i try to change the user mapping to sa it was giving me an error. your trick fixed the issue. i changed the owner of the database to some user and then change it back to sa

    Thanks a bunch!!!

    ReplyDelete
  5. Thanks Buddy! Super cool- Abhay

    ReplyDelete
  6. Nice move thanks! works smooth... magic!

    ReplyDelete