ASPNET Membership: Remove Users and Their Data

To remove inactive users or trouble users from your ASP.net Memebership tables use the following SQL script.

DECLARE @UserName nvarchar
SET @UserName = ‘USER NAME HERE’

DECLARE @UserId uniqueidentifier
SET @UserId = (SELECT UserId FROM aspnet_Users WHERE UserName = ‘Admin2017’)

DELETE FROM aspnet_Profile WHERE UserID = @UserId
DELETE FROM aspnet_UsersInRoles WHERE UserID = @UserId
DELETE FROM aspnet_PersonalizationPerUser WHERE UserID = @UserId
DELETE FROM aspnet_Membership WHERE UserID = @UserId
DELETE FROM aspnet_users WHERE UserID = @UserId

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s