I have stored values in my database that look like 5XXXXXX
, where X
can be any digit. In other words, I need to match incoming SQL query strings like 5349878
.
Does anyone have an idea how to do it?
I have different cases like XXXX7XX
for example, so it has to be generic. I don't care about representing the pattern in a different way inside the SQL Server.
I'm working with c# in .NET.
A Regular Expression is popularly known as RegEx, is a generalized expression that is used to match patterns with various sequences of characters. A RegEx can be a combination of different data types such as integer, special characters, Strings, images, etc.
Azure SQL Data Warehouse does not include support for Regular Expressions.
In other words, square brackets match exactly one character. (a-z0-9) will match two characters, the first is one of abcdefghijklmnopqrstuvwxyz , the second is one of 0123456789 , just as if the parenthesis weren't there. The () will allow you to read exactly which characters were matched.
An expression is a combination of one or more values, operators, and SQL functions that evaluate to a value. An expression generally assumes the datatype of its components.
You can write queries like this in SQL Server:
--each [0-9] matches a single digit, this would match 5xx SELECT * FROM YourTable WHERE SomeField LIKE '5[0-9][0-9]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With