Solved

SubString Query

Posted on 2007-03-27
1
439 Views
Last Modified: 2010-06-21
Hi there,

I am trying to retrieve a substring from a varchar column in the database. The column is used for storing email addresses and I am trying to sort the query by the domain names in the email address column.

Is there a charAt function in SQL Server I could use?

Anyone have the code to extract the domain name from the email address using sql server?
0
Comment
Question by:quanmac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 18803992
>>Is there a charAt function in SQL Server I could use?<<
CHARINDEX() is what you are looking for.

ORDER BY SUBSTRING(YourColumnName, CHARINDEX('@', YourColumnName) + 1, 256)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Part One of the two-part Q&A series with MalwareTech.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Six Sigma Control Plans

615 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