Merlin Nestler
Merlin Nestler

Reputation: 438

T-SQL LIKE - quantifiers

I get passed manual user input and have to build format tests in SQL Server to check whether user input conforms to expected input.

For example, an ID should start with two capital letters followed by 6 digits.

I know I can write the following:

WHERE Column like '[A-Z][A-Z][1-9][1-9][1-9][1-9][1-9][1-9]'

However, in other SQL dialects I saw that there is pattern quantification. In the TSQL documentation I didn't see this mentioned.

Is there a way to do something like the below? The curly braces signify how often a pattern shall be matched.

WHERE Column like '[A-Z]{2}[1-9]{6}'

Upvotes: 0

Views: 35

Answers (0)

Related Questions