Solved

SQL String functions

Posted on 2007-11-26
2
212 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:thehaze
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Mangus earned 250 total points
ID: 20351491
Try:

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

This scriptlet will fail if the @ is missing from an email address
0
 

Author Closing Comment

by:thehaze
ID: 31411022
Just what I was looking for.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question