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
 Update email

Author  Topic 

mmatthews0508
Starting Member

1 Post

Posted - 2012-08-01 : 15:28:47
We recently had a company that is in our database change their email schema. I am trying to do this through SQL so that I do not have to do all 200+ by hand. I need the domain to change, as well as making it lastname.firstname@newdomain.com

I have the following

UPDATE Name

SET name.EMAIL=REPLACE(dbo.name.email,'%@olddomain.com', '@newdomain.com')

So I can update the domain, but how do I make it read in the data for last name and first name and insert prior to the @newdomain.com?

Thanks in advance!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-08-01 : 15:36:40
So what you have is:
- the part '@newdomain.com'
- a column with lastname
- a column with firstname
then you can create that new mailaddress by concatenating the parts.
EMAIL=lastname+'.'+firstname+'@newdomain.com'



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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-01 : 16:37:53
howzz current format of email? does it have first and last names in it?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -