I want a SQL pattern expression to match all numbers between 1 and 999.
EDIT:
In MSSQL.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When using the LIKE operator pattern-matching in SQL for a character class, there’s no wildcard repeat of the character class like there is in regex. In other words, you can’t do things like
[0-9]+or[0-9]{1,3}(both of these would also capture0)So, you have to zero-pad the number before you can compare it.
It’s not directly a pattern, but this expression relies in part on the LIKE operator and will work for positive integers between 1 and 999:
Edit: assumption made that you’re talking about Microsoft SQL Server, since you didn’t specify.