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
Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.