SQL String functions

If I have an email address xxx.yyy@xxx.com, how do I use the SQL string functions to return the first part of the email address before the @. (xxx.yyy). Its not enough to use left() as the email address can vary in length.
thehazeAsked:
Who is Participating?
 
Chris MangusConnect With a Mentor Database AdministratorCommented:
Try:

Select Left(myEmailAddress, Patindex('%@%', myEmailAddress) -1) From myTable

This scriptlet will fail if the @ is missing from an email address
0
 
thehazeAuthor Commented:
Just what I was looking for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.