select left(emailaddress, len(emailaddress) - charindex('@', emailaddress))
I am getting the result below:
foo@ma
Please correct the select statement below. I need to do this with tones of email addresses and extract the username ONLY.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re inadvertently re-implementing “right” there 🙂
Try this:
It seeks the position of the
@, and takes the number of characters up to but not including (that’s the- 1) the@symbol.Be careful with strings that don’t have an
@though; you’ll end up an empty string.