I'd need to have a regular expression so that I can find all invalid email addresses in our database table.
SELECT *
FROM dbo.[Users] AS u
WHERE u.EmailAddress not like 'regular expression of valid email addresses'
Does SQL Server support regular expressions? If so, how could I write one for email address?
You can use RegEx in many languages like PHP, Python, and also SQL. RegEx lets you match patterns by character class (like all letters, or just vowels, or all digits), between alternatives, and other really flexible options.
MySQL supports another type of pattern matching operation based on the regular expressions and the REGEXP operator. It provide a powerful and flexible pattern match that can help us implement power search utilities for our database systems. REGEXP is the operator used when performing regular expression pattern matches.
T-SQL does not support regular expressions. You can however create a .net CLR function that will add this ability.
This might help.
http://www.simple-talk.com/sql/t-sql-programming/clr-assembly-regex-functions-for-sql-server-by-example/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With