Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split out name for email address

Status
Not open for further replies.

bhp

MIS
Jul 30, 2002
112
0
0
US
Hi does anyone know if possible to do the following:

Have a tabel that has UserName, e.g. "John Smith" and and column called emailaddress which is "jsmith' we want replace all "jsmith" with "John.smith@mycompany.com"
Is that possible?
Thanks - James
 
It would be much simplier if you would have name in separate columns (FirstName and LastName - we just discussed this issue recently).

Anyway, assuming always one space between two names you can do

update myTable set email = replace(Rtrim(Name), ' ','.') + '@myCompany.com')
 
No ) at the end - it's a typo.

Also, if you want smith in low case it's a bit harder, but you can use substring and charindex in this case.
 
thanks for super fast response was on similar lines :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top