white smartphone

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

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...