• matthew.hudsonbryan (4/22/2015)


    This version fixes the small mistake of the last and outputs the database name and username along with the drop statement to make it easier to see the users per database and have the drop statement available if required...<truncated>

    Hi Matthew,

    Thank you for taking the time to contribute an improvement to the script posted in the article, presumably from you picking it up and using it for your own admin needs. I posted on this thread in 2013 so received an email when you posted your comment. So that you are not sideswiped by the script and also to let other readers of this thread know not to use this script as-is, or even any close derivation of it, know that it has some major flaws that need to be addressed.

    Here are some things you should consider:

    1. the script still does not take into account Loginless Users so if you use this script as-is you have a chance of dropping a valid user: more reading[/url]

    2. the script uses sysusers, a compatibility view, and should be updated to use sys.database_principals: more reading

    3. the script uses undocumented proc sp_MSForEachDB which has gaping holes in it so be careful using it: more reading

    4. the script does not considers users in contained databases where the database manages the authentication: more reading

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato