SQL Server 101 – Extract Domain Name from Email Address

This was one of the quick task that I was required to work where i need to get the domain name from the email address.

How to extract domain name from email address in SQL Server ?

Assuming the table name is CustomerEmailAddress and we have a column called emailAdress.

Here’s a simple query demonstrating how to do this.

Select emailAdress, right(emailAddress, charindex('@', reverse(emailAddress))-1) 
FROM CustomerEmailAddress

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...