You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/functions/regexp-like-transact-sql.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: REGEXP_LIKE Returns a Boolean value that indicates whether the text
4
4
author: MikeRayMSFT
5
5
ms.author: mikeray
6
6
ms.reviewer: abhtiwar, wiassaf, randolphwest
7
-
ms.date: 11/18/2025
7
+
ms.date: 11/21/2025
8
8
ms.service: sql
9
9
ms.subservice: t-sql
10
10
ms.topic: reference
@@ -31,7 +31,7 @@ REGEXP_LIKE
31
31
32
32
`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.
33
33
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:
35
35
36
36
```sql
37
37
ALTERDATABASE [DatabaseName]
@@ -63,22 +63,30 @@ Boolean value. `true` or `false`.
63
63
64
64
### Cardinality estimation
65
65
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).
67
67
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.
69
69
70
70
To disable the automatic feedback behavior, enable trace flag 16268.
71
71
72
72
## Examples
73
73
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`:
75
75
76
76
```sql
77
77
SELECT*
78
78
FROM Employees
79
79
WHERE REGEXP_LIKE (FIRST_NAME, '^A.*Y$');
80
80
```
81
81
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
+
82
90
Select all records from the `Orders` table where the order date is in February 2020:
83
91
84
92
```sql
@@ -95,7 +103,7 @@ FROM Products
95
103
WHERE REGEXP_LIKE (PRODUCT_NAME, '[AEIOU]{3,}');
96
104
```
97
105
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:
0 commit comments