change dbo login name

  • I have a database that I need to change the dbo owner from user A to user B. I'm getting different errors.

    When I try to change it I get the error that the user B is already mapped. What's the process to change the owner of a database?

    When I ran the scrip below

    select

    u.name

    , s.name

    from sysusers u

    inner join master.dbo.syslogins s

    on u.sid = s.sid

    I get:

    name name

    dbo domain\userA

    domain\userB domain\UserB

    I tried dropping user B but I cannot change the db owner to userB

    Thank you.

  • Login B is a user in the database.

    You must first drop B as a user in the database, and then you can map the login to the explicit dbo of thedatabase

  • I dropped userB from the database and I tried changing the owner of the databases by going through the database properties and changing the dbo user that way under the file properties. It throws an error timing out.

    I also tried running sp_changedbuser 'userB' and the query never seems to finish. I tried changing the dbo owner to sa but I also get the same results.

    user A is a sysadmin. user B is just a regular domain account which I need to have as the dbo on that database.

  • HildaJ (7/1/2013)


    I also tried running sp_changedbuser 'userB' and the query never seems to finish.

    Run the action again and look in the activity monitor (or use sp_who or something else) for any blocking processes. Chances are the action to change the owner is getting blocked by the regular actions going on in the database.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • HildaJ (7/1/2013)


    I have a database that I need to change the dbo owner from user A to user B. I'm getting different errors.

    When I try to change it I get the error that the user B is already mapped. What's the process to change the owner of a database?

    When I ran the scrip below

    select

    u.name

    , s.name

    from sysusers u

    inner join master.dbo.syslogins s

    on u.sid = s.sid

    I get:

    name name

    dbo domain\userA

    domain\userB domain\UserB

    I tried dropping user B but I cannot change the db owner to userB

    Thank you.

    The user marked as the db owner on the files page of the database properties maps in as dbo. Change the database owner account to be user b and that user will map as dbo

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Well, a new day and new outcomes. After struggling with this problem for a half a day yesterday, this is what I did this morning.

    1) Added a new dummy user with sysadmin access

    2) Changed the owner of the database (properties-->files) to this new user account

    3) Dropped userB from the database

    4) Change the owner of the database to UserB

    This worked. Even though I had dropped the UserB before and ran the sp_changedbuser script and tried to change the properties these didn't work. I guess I needed to freed up userA before.

    I hope what I did helps others.

    Thank you all for your replies, I really appreicated. This forumn is great, there's always someone to give a little help.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply