• 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:

    ------------------------------------

    Doe.John@CompanyABC.com

    (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))

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]