Skip to content

Instantly share code, notes, and snippets.

@Spaider
Created May 17, 2013 14:19
Show Gist options
  • Save Spaider/5599325 to your computer and use it in GitHub Desktop.
Save Spaider/5599325 to your computer and use it in GitHub Desktop.
Updates membership email from email in racer details.
Declare @oldEmail Varchar(100) = '<specify old email here>'
Declare @newEmail Varchar(100)
Declare @racerID Int
Declare @userId Uniqueidentifier
Set @userId = (Select am.UserId From aspnet_Membership am Where am.Email Like @oldEmail)
Print 'User ID: ' + Cast(@userId As Varchar(45))
Set @racerID = (
Select
Cast(Cast(ap.PropertyValuesString As Varchar) As Bigint)
From
aspnet_Profile ap
Where
ap.UserId = @userId)
If @racerID Is Null
BEGIN
Print 'Racer not found'
Return
End
Set @newEmail = (Select rd.RCR_Email From vr_t_RacerDetail rd Where rd.RCR_RacerID = @racerID)
Print 'Update email from ' + @oldEmail + ' to ' + @newEmail
Update aspnet_Membership
Set
Email = @newEmail,
LoweredEmail = Lower(@newEmail)
Where
UserId = @userId
Print 'Done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment