Sunday, 24 May 2009

Using PATINDEX for Regular Expressions in T-SQL

I recently needed to perform some validation using regular expressions in T-SQL rather than C#. Fortunately, this is easily accomplished using the PATINDEX keyword. For example:

PATINDEX('[^0-9]%',@Input)

The above example would check that the variable @Input does not begin with a numeric character.

Labels: ,

Bookmark and Share

0 Comments:

Post a Comment



<< Home