kd11 (11/20/2012)
the code you posted just give the lastname and company.com (doe@CompanyABC.com). I'm here Doe.John@CompanyABC.com And I want to get to John.Doe@CompanyABC.com
Not true. I've tested it:
declare @email varchar(100) = 'Doe.John@CompanyABC.com'
select SUBSTRING(@Email, -1, CHARINDEX('.', @Email) +1) +
SUBSTRING(@Email, CHARINDEX('.', @Email), LEN(@Email))
returns:
------------------------------------
(1 row(s) affected)
What are you using? SQL2008?
You may try another version:
declare @email varchar(100) = 'Doe.John@CompanyABC.com'
select SUBSTRING(@Email, 0, CHARINDEX('.', @Email)) +
SUBSTRING(@Email, CHARINDEX('.', @Email), LEN(@Email))