Been looking all over for this and I don't think nested replace is the answer. I have a list of email address that I need to keep unique, but I need to make them all fake for testing. So my idea was to just replace the '.com', '.net', '.org' and so on to '.mydomain.com'. But there are a LOT of endings in total.
I realized I could just remove the @ and add '@mydomain.com' to the end, but now I also want to figure out how to solve this particular problem.
Instead of doing:
BEGIN TRANSACTION;
UPDATE Customer
SET Email=REPLACE(Email, '.com','.mydomain.com')
where email not like '%.mydomain.com%'
COMMIT TRANSACTION;
for each case '.com', '.net', '.org'........
is there a way to say, replace all of these ('.com', '.net', '.org') with '.mydomain.com' in one statement?
something like this.
BEGIN TRANSACTION;
UPDATE Customer
SET Email=REPLACE(Email, (in ('.com', '.net', '.org')),'.mydomain.com')
where email not like '%.mydomain.com%'
COMMIT TRANSACTION;