Skip to content

Commit a5dd253

Browse files
Merge pull request #35910 from rwestMSFT/rw-1121-fix-10228
Refresh REGEXP_LIKE and add example (PR 10228)
2 parents 3143672 + 30d81ed commit a5dd253

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

docs/t-sql/functions/regexp-like-transact-sql.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: REGEXP_LIKE Returns a Boolean value that indicates whether the text
44
author: MikeRayMSFT
55
ms.author: mikeray
66
ms.reviewer: abhtiwar, wiassaf, randolphwest
7-
ms.date: 11/18/2025
7+
ms.date: 11/21/2025
88
ms.service: sql
99
ms.subservice: t-sql
1010
ms.topic: reference
@@ -31,7 +31,7 @@ REGEXP_LIKE
3131

3232
`REGEXP_LIKE` requires database compatibility level 170 and above. If the database compatibility level is lower than 170, `REGEXP_LIKE` isn't available. Other [regular expression scalar functions](regular-expressions-functions-transact-sql.md) are available at all compatibility levels.
3333

34-
You can check compatibility level in the `sys.databases` view or in database properties. You can change the compatibility level of a database with the following command:
34+
You can check the compatibility level in the `sys.databases` view or in database properties. You can change the compatibility level of a database with the following command:
3535

3636
```sql
3737
ALTER DATABASE [DatabaseName]
@@ -63,22 +63,30 @@ Boolean value. `true` or `false`.
6363

6464
### Cardinality estimation
6565

66-
To enhance the accuracy of [cardinality estimation](../../relational-databases/performance/cardinality-estimation-sql-server.md) for the `REGEXP_LIKE` function, you can use the `ASSUME_FIXED_MIN_SELECTIVITY_FOR_REGEXP` and `ASSUME_FIXED_MAX_SELECTIVITY_FOR_REGEXP` query hints to adjust the default selectivity values. For more information, see [Query hints](../queries/hints-transact-sql-query.md#use_hint).
66+
To enhance the accuracy of [cardinality estimation](../../relational-databases/performance/cardinality-estimation-sql-server.md) for the `REGEXP_LIKE` function, use the `ASSUME_FIXED_MIN_SELECTIVITY_FOR_REGEXP` and `ASSUME_FIXED_MAX_SELECTIVITY_FOR_REGEXP` query hints to adjust the default selectivity values. For more information, see [Query hints](../queries/hints-transact-sql-query.md#use_hint).
6767

68-
These query hints are also integrated with [Cardinality estimation (CE) feedback](../../relational-databases/performance/intelligent-query-processing-cardinality-estimation-feedback.md). The CE feedback model automatically identifies queries using `REGEXP_LIKE` function where there's a significant difference between estimated and actual row counts. It then applies the appropriate selectivity hint at the query level to improve plan quality without requiring manual input.
68+
These query hints also integrate with [Cardinality estimation (CE) feedback](../../relational-databases/performance/intelligent-query-processing-cardinality-estimation-feedback.md). The CE feedback model automatically identifies queries that use the `REGEXP_LIKE` function where there's a significant difference between estimated and actual row counts. It then applies the appropriate selectivity hint at the query level to improve plan quality without requiring manual input.
6969

7070
To disable the automatic feedback behavior, enable trace flag 16268.
7171

7272
## Examples
7373

74-
Select all records from the `Employees` table where the first name starts with `A` and ends with `Y`
74+
Select all records from the `Employees` table where the first name starts with `A` and ends with `Y`:
7575

7676
```sql
7777
SELECT *
7878
FROM Employees
7979
WHERE REGEXP_LIKE (FIRST_NAME, '^A.*Y$');
8080
```
8181

82+
Select all records from the `Employees` table where the first name starts with `A` and ends with `Y`, using case-insensitive mode:
83+
84+
```sql
85+
SELECT *
86+
FROM Employees
87+
WHERE REGEXP_LIKE (FIRST_NAME, '^A.*Y$', 'i');
88+
```
89+
8290
Select all records from the `Orders` table where the order date is in February 2020:
8391

8492
```sql
@@ -95,7 +103,7 @@ FROM Products
95103
WHERE REGEXP_LIKE (PRODUCT_NAME, '[AEIOU]{3,}');
96104
```
97105

98-
Create employees table with `CHECK` constraints for `Email` and `Phone_Number` columns:
106+
Create an employees table with `CHECK` constraints for the `Email` and `Phone_Number` columns:
99107

100108
```sql
101109
DROP TABLE IF EXISTS Employees;

0 commit comments

Comments
 (0)