EXCEL / SQL SERVER – Extract the Domain from an Email Address

Just like any business person, I work with Excel pretty much half of my time when I am not working with SQL Server. Recently I faced challenges when I wanted to extract domain from the email address. I was using excel. I was in extreme rush so I did something which was in fact actually longer route than easier way. I laughed at myself and decided to blog about it.

Here is the way I took to extract domain out of email in excel.

  1. Imported Excel to SQL Server Table
  2. Executed script from my blog post to extract domain from email in SQL Server
  3. Exported SQL Server Table to Excel

In reality, I should just have written a new function in different columns of excel which can extract domain out of Excel.

Here is the function which will extract domain from the email address.

=MID(B2,SEARCH(“@”,B2)+1,255)

Following is the image which displays how above simple excel function can return the domain from the email address.

EXCEL / SQL SERVER - Extract the Domain from an Email Address excelemail

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Finding Max Value From Multiple Values
Next Post
SQL SERVER – Combined Multiple .SQL files into One Single File

Related Posts

No results found.

2 Comments. Leave new

  • I think you can simply use Text to Column feature of Excel by delimiting ‘@’ of email address.

    Reply
  • i think it will be =MID(B2,SEARCH(“@”,B2),1,255) instead of =MID(B2,SEARCH(“@”,B2)+1,255)

    Reply

Leave a Reply