Home Forums SQL Server 2005 Administering Query to Delete all User defined schemas, roles and users RE: Query to Delete all User defined schemas, roles and users

  • Something like:

    select 'drop user ' + name + ';'

    from sys.database_principals

    WHERE type = 's';

    Copy-and-paste the results into a window in Management Studio, delete the ones you want to keep, and then run it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon