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
 Mass update to partial field

Author  Topic 

dzabor
Posting Yak Master

138 Posts

Posted - 2008-07-29 : 10:34:55
I have a request to update all email addresses in a database to use our company domain. For example:

Update mickeymouse@yahoo.com to mickeymouse@CompanyName.com

This is for testing purposes on a development db.

Is there a way to accomplish this?

Thanks,
dz

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-29 : 10:57:33
UPDATE yourtable
SET emailfield= LEFT(emailfield,CHARINDEX ('@',emailfield)-1)+'YourCompanyName.com'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-30 : 02:57:17
or

UPDATE yourtable
SET emailfield= replace(emailfield,'yahoo.com','YourCompanyName.com')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 03:17:38
quote:
Originally posted by madhivanan

or

UPDATE yourtable
SET emailfield= replace(emailfield,'yahoo.com','YourCompanyName.com')

Madhivanan

Failing to plan is Planning to fail


Not sure if email address will always have yahoo.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-30 : 04:07:21
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

or

UPDATE yourtable
SET emailfield= replace(emailfield,'yahoo.com','YourCompanyName.com')

Madhivanan

Failing to plan is Planning to fail


Not sure if email address will always have yahoo.com


Good point. Omit my previous reply

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -