Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

E-Mail Validator

By Sean Smith, 2009/12/09

Simply pass a field which contains an e-mail address to the function and either a 1 (valid) or 0 (invalid) will be returned as output.

This routine is not meant to be an all-encompassing solution for identifying invalid e-mail addresses, but rather a quick / easy check routine to catch obvious errors and mistakes.

Examples of how to run the function:

SELECT
dbo.ufn_E_Mail_Validator ('me@nowhere.com') AS is_valid_yes
,dbo.ufn_E_Mail_Validator ('me@@nowhere.com') AS is_valid_no

Or... against a table, returning only invalid e-mail addresses (NULL values are considered valid by the function as they are essentially "unknown"):

SELECT
CC.e_mail
,dbo.ufn_E_Mail_Validator (CC.e_mail) AS is_valid
FROM
dbo.company_contact CC
WHERE
dbo.ufn_E_Mail_Validator (CC.e_mail) = 0

Total article views: 1705 | Views in the last 30 days: 5
 
Related Articles
SCRIPT

SQL CLR Function for Email validation and string Split

I have added 2 functions here, one for email validation and another to split the string by specified...

BLOG

Powershell – Validating an IP Address

  A task that I have had to do several times over the years is determine if an IP Address string......

ARTICLE

Geocode Addresses in T-SQL

Geocode, look up postal codes, and perform validation for street address information natively T-SQL

FORUM

TSQL error: 'Invalid length parameter passed to the substring function.'

TSQL error: 'Invalid length parameter passed to the substring function.'

FORUM

Removing invalid email addresses

I have a 4 million row table with emails from different sources. I need to clean it up and only ha...

Tags
address    
email    
e-mail    
validation    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones