Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Exclude a subset from SQL operation

Author  Topic 

tmccar
Starting Member

27 Posts

Posted - 2012-07-06 : 07:48:09
I want to change the email addresse domain of a group of users, which are in a table called "users", in the "email" column. I want to exclude some email addresses

This is the command I am using:
update users
Set email = replace(email, 'cae.org', 'cae.com');

except where email = (person1@cae.org, person2.cae.org, person3@cae.org);


Does this look ok? I think the first part is ok, but I'm not sure about the "except" part.













webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-06 : 07:52:57
update users
Set email = replace(email, 'cae.org', 'cae.com')
where email like '%cae.org'
and email not in('person1@cae.org', 'person2.cae.org', 'person3@cae.org')



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tmccar
Starting Member

27 Posts

Posted - 2012-07-06 : 09:21:25
Many thanks, that works great.
Go to Top of Page
   

- Advertisement -