> ## Content Index
> Fetch the complete content index at: https://blog.tsd.digital/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to: Remove users from the ASP.Net membership database
- URL: https://blog.tsd.digital/how-to-remove-users-from-the-aspnet-membership-database/
- Published: 2008-01-13T20:37:44.000Z
- Updated: 2008-01-13T20:37:44.000Z
- Author: Tim Gaunt
- Tags: ASP.Net, Web Development, .Net, #Import 2025-04-01 05:37

I'm sure I've blogged about this in the past -or perhaps it's just in my "to blog about list" but I thought I would share this little ditty on the Sunday night. 

If you ever need to delete a user from your ASP.Net Membership database this is a really useful SQL script to do just that (I often find that the ASP.Net web administration tool throws a SQL Exception while trying to delete a user).

To use the code to delete a user from the ASP.Net membership database simple identify the Guid of the user and enter it where I've written 'THE GUID OF THE USER HERE' and hit go :)

USE ASPNetGODECLARE@UserIduniqueidentifierSET@UserId = 'THE GUID OF THE USER HERE'DELETEFROM aspnet\_Profile WHERE UserID = @UserIdDELETEFROM aspnet\_UsersInRoles WHERE UserID = @UserIdDELETEFROM aspnet\_PersonalizationPerUser WHERE UserID = @UserIdDELETEFROM dbo.aspnet\_Membership WHERE UserID = @UserIdDELETEFROM aspnet\_users WHERE UserID = @UserId

The message I was referring to above usually looks something like the following:

Msg 547, Level 16, State 0, Line 9The DELETE statement conflicted with the REFERENCE constraint "FK\_\_aspnet\_Us\_\_UserI\_\_17036CC0". The conflict occurred in database "ASPNetMemberships", table "dbo.aspnet\_UsersInRoles", column 'UserId'.The statement has been terminated.

I've not looked into why it's happening (I expect it's something to do with an incorrect install on my behalf) but I'm sure there's a solution for it. I know there are a couple of built in SQL scripts i.e. aspnet\_Users\_DeleteUser but they required more params to get working ;)