nov 8 blog scripts SQL Reports T-SQL

Validate email address with T-SQL and regular expressions

I needed an easy way of validation email addresses in a SQL database, this is the outcome from it:

–Select all records in the entity

select id, name, emailaddress from table1

–The except compare the two dataset and output the difference
EXCEPT

–Select all records in the entity again now with the expression on
select id, name, emailaddress from table1
where emailaddress not like ‘%[^([a-zA-Z0-9_-.]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$]%’
and emailaddress like ‘%_@_%_.__%’

 

Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+

Skriv et svar

Din e-mailadresse vil ikke blive offentliggjort. Krævede felter er markeret med *