ASPNET Membership: Remove Users and Their Data

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

DECLARE @UserName nvarchar

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: Logo

You are commenting using your 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