Friday, March 1, 2013

Bulk Delete Asp.Net Membership Users


You can use below select statement according to your requirement. Please use one of the select statement. Be care full before running the script as it deletes all the users based on where condition.



SELECT UserID, Email
INTO #temp
FROM aspnet_Membership
WHERE Email like '%tech%'

or

SELECT UserID, UserName
into #temp
FROM aspnet_Users
WHERE UserName in ('test')


DELETE FROM dbo.aspnet_Membership WHERE UserId IN (Select UserId from #temp)
DELETE FROM dbo.aspnet_UsersInRoles WHERE UserId IN (Select UserId from #temp)
DELETE FROM dbo.aspnet_Profile WHERE UserId IN (Select UserId from #temp)
DELETE FROM dbo.aspnet_PersonalizationPerUser WHERE UserId IN (Select UserId from #temp)
DELETE FROM dbo.aspnet_Users WHERE UserId IN (Select UserId from #temp)

DROP TABLE #temp





No comments:

Post a Comment

Followers