Removing a user from a database

  • Guys,

     

    I did a restore a database backup file to another database. From the restore file, there is a user who is also a dbo. I would like to delete this user from my new database and I am having problem. I have change the user role from dbo to something else and it did not work. Help Please!

  • What is the error message(s) you are receving ?

  • Make another user the owner of the database, and then delete the user you want to get rid of.

     

     

  • The database owner can be changed through sp_changedbowner

    Than you can simply delete that user if he doesn't own other database objects. If you need to change object owner than you can use sp_changeobjectowner

    For the correct syntax you may look at BOL

  • First of all you need to tell us the exact error which you are getting.

    Secondly you will have to check as to what all objects are owned by this login and then  you will have to change the owner of these objects to some other  owner. After that you will be able to drop this user.

    to change the owner for all the tables

    sp_MSForEachTable 'sp_changeobjectowner ''?'',''OwnerNameHere'''

     

     

  • it isint as complicated as it seems.

    just make any other login the owner of the database

    use dbaname

    sp_changedbowner 'sa'

    then you should be able to delete the user sucessfully

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

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