How to use regular expression in TSQL?

The Light picture The Light · Dec 7, 2011 · Viewed 19.5k times · Source

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?

Answer

Doug Chamberlain picture Doug Chamberlain · Dec 7, 2011

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/