Here's a quick hot fix for everyone out there frustrated with not being able to delete users from their community and are receiving this error, or something similar(Please remember to always backup your database):
The DELETE statement conflicted with the REFERENCE constraint "FK_cs_Wiki_Pages_cs_Users". The conflict occurred in database "clientintellectcore", table "dbo.cs_Wiki_Pages", column 'UserId'.
The statement has been terminated.
The problem here is a little something the developers left out of the cs_User_Delete stored procedure that reassignes Wiki pages to the anonymous or specified user. So in this case, the user is attempted to be deleted, and SQL finds that the cs_Wiki_Pages table still contains a reference to a user no longer there, and thus throws a reference constraint. To eliminate the problem is pretty simple, just adding about four lines to a stored procedure. First open up your SQL Server Management Studio and navigate to your CS database. Then inside Programmability->Stored Procedures, locate the cs_User_Delete Stored Procedure(Sproc). Right click that sproc and select "Modify". Scroll down until you see the below line:
EXECUTE cs_Posts_ReindexByUser @UserID
IF (@@ERROR <> 0) GOTO
-- reassign content
Then just below that add these specific four lines:
UPDATE cs_Wiki_Pages
SET UserID = @ReassignUserID
WHERE UserID = @UserID
IF (@@ERROR <> 0) GOTO Failure
Now hit F5 or Execute and modify the Sproc. Your site should now be able to delete users!
