Nik's Technology Blog

Travels through programming, networks, and computers

Anonymizing user data from an aspnet Membership database

Use this T_SQL script to anonymize data from ASP.NET's Membership database.

 

declare @email varchar(255)
set @email = 'email_to_delete@gmail.com'

update aspnet_profile 
set PropertyNames = '', PropertyValuesString = '' 
where UserId = (
SELECT UserId
FROM aspnet_Membership 
where Email = @email
)

update aspnet_Membership 
set Email = 'deleted@deleted.com', LoweredEmail = 'deleted@deleted.com', IsApproved = 0, PasswordQuestion = 'deleted', PasswordAnswer = 'deleted', [Password] = 'deleted'
where UserId = (
SELECT UserId
FROM aspnet_Membership 
where Email = @email
)