Find the domain name from email address – SQL Server

Recently in one of my own project I had to find out the domain names from an email address column and then get the counts of registered email ids by domain name. There I realized I was being asked a similar kind of question couple of years ago in an interview. So I thought to write a blog about it and solve the same here using different methods.


Using the split function:
This is a simple split function to split delimited string.

Using STUFF:

Using LEFT:

Using RIGHT:

Using XML:


Prasad Sahoo

Prasad Sahoo, is an enthusiast of Microsoft technologies in general and a passionate database professional, mainly focusing on SQL Server performance tuning and business intelligence. He has contributed a long time of his career working on SQL Server and other RDBMS. If he is not busy with SQL stuff then he must be watching some Hollywood movies.

One thought on “Find the domain name from email address – SQL Server

  • December 27, 2014 at 2:10 am

    Another great article.. keep up the good work


Leave a Reply

%d bloggers like this: