﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / Query to Delete  all User defined schemas, roles and users / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 17:46:57 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query to Delete  all User defined schemas, roles and users</title><link>http://www.sqlservercentral.com/Forums/Topic1067181-146-1.aspx</link><description>Something like:[code="sql"]select 'drop user ' + name + ';'from sys.database_principalsWHERE type = 's';[/code]Copy-and-paste the results into a window in Management Studio, delete the ones you want to keep, and then run it.</description><pubDate>Tue, 22 Feb 2011 08:46:29 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>RE: Query to Delete  all User defined schemas, roles and users</title><link>http://www.sqlservercentral.com/Forums/Topic1067181-146-1.aspx</link><description>Hi Is there any query as such to remove all users except sa and system account users ?</description><pubDate>Tue, 22 Feb 2011 07:29:35 GMT</pubDate><dc:creator>RamSteve</dc:creator></item><item><title>RE: Query to Delete  all User defined schemas, roles and users</title><link>http://www.sqlservercentral.com/Forums/Topic1067181-146-1.aspx</link><description>You could write one, using various system views, a couple of cursors, and some light-weight dynamic SQL.However, I have to question "deleting all user-defined users" in the database.  That'll pretty much get rid of all user accounts except guest and sa.</description><pubDate>Mon, 21 Feb 2011 12:03:41 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>Query to Delete  all User defined schemas, roles and users</title><link>http://www.sqlservercentral.com/Forums/Topic1067181-146-1.aspx</link><description>Hi Is there any Query to delete all User defined schemas, roles and users in database .Thanks in Advance :)</description><pubDate>Mon, 21 Feb 2011 09:57:41 GMT</pubDate><dc:creator>RamSteve</dc:creator></item></channel></rss>