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

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

E-Mail Validator

By Sean Smith,

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: 1799 | Views in the last 30 days: 6
 
Related Articles
ARTICLE

Excel Function Returns Cell Address

This article details an Excel 2010 function to return the cell address of min and max functions.

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.'

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