I am trying to find a way to validate data in my columns using regex CHECK constraints but have so far only come across the LIKE keyword that has an extremely limited subset of regex syntax. I’d like to know if there is a way to use regex in check constraints?
I am using SQL Server 2005 and 2008.
I think you can create a CLR scalar UDF which can use the .Net framework RegEx classes, and then call that from your check constraint.
In fact, this article discusses this scenario (search for “Check Constraint”, then move backwards through the article to find implementation details).