Delete All Database User Accounts for a Given Server Login

  • Comments posted to this topic are about the item Delete All Database User Accounts for a Given Server Login

    Hakim Ali
    www.sqlzen.com

  • This is good topic but I want to delete 2 users forcefully from 253 databases then how can i do it?

  • Prat!K (4/14/2014)


    This is good topic but I want to delete 2 users forcefully from 253 databases then how can i do it?

    Towards the top of my script there is this line:

    set @LoginName = 'LOGIN_NAME_HERE'

    Set the server level login name associated with one of your users here, and run the script. Then set @LoginName to the login name of your other user, and run the script again. This will accomplish what you want. I'm assuming these two users and the 253 databases are on the same server. If they are on more than one server, just repeat the process on each server.

    Hakim Ali
    www.sqlzen.com

  • Great script, thanks.

  • Nice Script. If anyone do not want to drop the user just change that to "Select" so that you can check what are the results before droping the user.

    select@sql = 'use [' + DB + ']; select user [' + UserName + ']'

    Thanks.

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

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