I have a table in SQL Server and a column ( consider the column is of varchar or INT data type), The column has values and most of them are integers.
How can I query only integers with length 3, not more than 3 or less than 3 using Regular Expression? is it possible in SQL Server? do I need to install any additional libraries?
Input
column
- 123
- 234
- 4532
- 223
- 2e34
- 234
- 22
- 23344
Expected Output:
Column
- 123
- 234
- 223
- 234
CodePudding user response:
SQL Server does not have Regex. Even if it did, I wouldn't recommend it here
You can just use a cast and BETWEEN
WHERE TRY_CAST(YourColumn AS int) BETWEEN 100 AND 999
If the column is actually an int
then you don't even need a cast.