{"id":85,"date":"2011-11-15T21:35:19","date_gmt":"2011-11-16T02:35:19","guid":{"rendered":"http:\/\/blogs.visigo.com\/chriscoulson\/?p=85"},"modified":"2011-11-15T21:35:19","modified_gmt":"2011-11-16T02:35:19","slug":"bulk-delete-asp-net-membership-users","status":"publish","type":"post","link":"https:\/\/blogs.visigo.com\/chriscoulson\/bulk-delete-asp-net-membership-users\/","title":{"rendered":"Bulk Delete ASP.NET Membership Users"},"content":{"rendered":"<p>Below is a SQL script that can be used to delete a list of users from an ASP.NET membership database. \u00a0It retrieves a list of users into a temporary table and then deletes the users from all the relevant tables in the database.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT UserID, UserName\r\ninto #temp\r\nFROM aspnet_Users\r\nWHERE UserName in ('MEMBER10001','MEMBER10002','MEMBER10003','MEMBER10004','MEMBER10005')\r\n\r\n-- Adjust the WHERE Clause to filter the users\r\n-- for example WHERE UserName LIKE 'MEMBER%'\r\n-- would delete all users whose username started with 'MEMBER'\r\n\r\nDELETE FROM dbo.aspnet_Membership WHERE UserId IN (Select UserId from #temp)\r\n\r\nDELETE FROM dbo.aspnet_UsersInRoles WHERE UserId IN (Select UserId from #temp)\r\n\r\nDELETE FROM dbo.aspnet_Profile WHERE UserId IN (Select UserId from #temp)\r\n\r\nDELETE FROM dbo.aspnet_PersonalizationPerUser WHERE UserId IN (Select UserId from #temp)\r\n\r\nDELETE FROM dbo.aspnet_Users WHERE UserId IN (Select UserId from #temp)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Below is a SQL script that can be used to delete a list of users from an ASP.NET membership database. \u00a0It retrieves a list of users into a temporary table and then deletes the users from all the relevant tables in the database. SELECT UserID, UserName into #temp FROM aspnet_Users WHERE UserName in (&#8216;MEMBER10001&#8242;,&#8217;MEMBER10002&#8242;,&#8217;MEMBER10003&#8242;,&#8217;MEMBER10004&#8242;,&#8217;MEMBER10005&#8217;) &#8212; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[178,19,3],"tags":[321,94,41,179,21,181,180,18,27],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-asp-net-membership-net","category-forms-based-authentication","category-sql-server","tag-net","tag-asp-net","tag-asp-net-membership","tag-delete-users","tag-membership","tag-script","tag-sql","tag-sql-server-2","tag-users"],"_links":{"self":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":0,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.visigo.com\/chriscoulson\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}