Cloud Training (Online)

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
Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.