August 23, 2006 at 8:48 am
Hi,
I need to make I slight change to 204 lines on emails addresses that are in one column. Eg. from: myname@abc.com to myname@acb.com. Is there a way I could iterate and update through the email column of this table?
August 23, 2006 at 9:30 am
Hello,
You can use Replace function to update the domain name in your email address:
update <tablename>
set <columnname> = replace(columnname, 'abc', 'acb')
Note: it will replace for all the data rows in your table.
Lucky
August 24, 2006 at 3:55 am
Beware that this might be dangerous if you only want to change the part after the @ sign and before the first .
The above could potentially change also the first part of the email address if it contains the string.
Maybe you should also look at PARSENAME( ... , ... )
Try:
SELECT PARSENAME('myFirstPart@mysecondPart.myThirdPart.myExtension',1)
SELECT PARSENAME('myFirstPart@mysecondPart.myThirdPart.myExtension',2)
SELECT PARSENAME('myFirstPart@mysecondPart.myThirdPart.myExtension',3)
SELECT PARSENAME('myFirstPart@mysecondPart.myThirdPart.myExtension',4)
It will return the PART of the string between two DOTs (think replace @ with . )
Then you can concatenate your parts again to get your email address (if you concatenate correctly)
Hanslindgren
August 24, 2006 at 4:15 am
Thanks for the quick replies guys. I had already used the first solution, but then I realised it changed any instance of the old value I was trying to replace. Thankfully there were just of them. Again thanks for the help.
August 24, 2006 at 4:18 am
No problem, most important is that you managed to get help here
And that you provided feedback that it actually did help. Too often one writes comments/replies without ever knowing if it was beneficial or just a waste of time.
Happy coding,
Hanslindgren
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy