Link to home
Start Free TrialLog in
Avatar of Marcos27
Marcos27Flag for United States of America

asked on

SQL Statement to Update Email Domain

Hello Experts -

I need an SQL update statement to execute against a column in my 'user' table called 'email'. Right now, it contains similar emails for all of my users: mary.jones@blue.com, brian.hall@blue.com etc. The company (email domain) has just changed names to something entirely different, so they all need to now be mary.jones@white.com, brian.hall@white.com etc. The change is the same for everyone, two entirely unique company names, so, from @blue.com to @white.com.

Will this statement work? I'm on SQL 2008.

UPDATE user SET email = replace(email,'@blue.com','@white.com') WHERE email LIKE '%@blue.com';

I'm going to test and backup, but I just want to make sure the above function does what I think it's going to do. Any suggestions are helpful.

Thank you,
Marcos
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of awking00
>>Will this statement work?<<
Run it as a select statement first then see (you might want to limit the number of rows).
select replace(email,'@blue.com','@white.com') from user WHERE email LIKE '%@blue.com';