【发布时间】:2022-12-02 06:27:27
【问题描述】:
I have the following values
ABCD_AB_1234
ABCD_ABC_2345
ABCD_ABCD_5678
and a regular expression to match them
ABCD_[A-Z]{2-4}_[0-9]{4}
Now I am looking to convert that regular expression to a SQL query so I can get those records back from the database.
Right now I have following where clause
where [columnName] like 'ABCD_[A-Z][A-Z]%[_][0-9][0-9][0-9][0-9]%'
The problem is that I cannot define a range in the SQL query as I did in the regular expression, like {2-4}, what I am doing now is to set the minimum range only.
Is there any solution?
【问题讨论】:
-
Don't confuse pattern matching for full regex, SQL Server does not (natively) support it.
标签: sql-server tsql