Skip to content

Commit 45dcabb

Browse files
committed
Add TRIM
1 parent 144e696 commit 45dcabb

File tree

1 file changed

+33
-50
lines changed
  • articles/cosmos-db/nosql/query

1 file changed

+33
-50
lines changed
Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,53 @@
11
---
2-
title: TRIM in Azure Cosmos DB query language
3-
description: Learn about SQL system function TRIM in Azure Cosmos DB.
4-
author: ginamr
2+
title: TRIM
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a string with leading or trailing whitespace trimmed.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 09/14/2021
9-
ms.author: girobins
10-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/24/2023
12+
ms.custom: query-reference
1113
---
12-
# TRIM (Azure Cosmos DB)
14+
15+
# TRIM (NoSQL query)
16+
1317
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1418

15-
Returns a string expression after it removes leading and trailing whitespace or specified characters.
16-
19+
Returns a string expression after it removes leading and trailing whitespace or custom characters.
20+
1721
## Syntax
18-
22+
1923
```sql
20-
TRIM(<str_expr1>[, <str_expr2>])
21-
```
22-
24+
TRIM(<string_expr_1> [, <string_expr_2>])
25+
```
26+
2327
## Arguments
24-
25-
*str_expr1*
26-
Is a string expression
2728

28-
*str_expr2*
29-
Is an optional string expression to be trimmed from str_expr1. If not set, the default is whitespace.
29+
| | Description |
30+
| --- | --- |
31+
| **`string_expr_1`** | A string expression. |
32+
| **`string_expr_2` *(Optional)*** | An optional string expression with a string to trim from `string_expr_1`. If not specified, the default is to trim whitespace. |
3033

3134
## Return types
32-
33-
Returns a string expression.
34-
35+
36+
Returns a string expression.
37+
3538
## Examples
36-
37-
The following example shows how to use `TRIM` inside a query.
38-
39-
```sql
40-
SELECT TRIM(" abc") AS t1,
41-
TRIM(" abc ") AS t2,
42-
TRIM("abc ") AS t3,
43-
TRIM("abc") AS t4,
44-
TRIM("abc", "ab") AS t5,
45-
TRIM("abc", "abc") AS t6
46-
```
47-
48-
Here is the result set.
49-
50-
```json
51-
[
52-
{
53-
"t1": "abc",
54-
"t2": "abc",
55-
"t3": "abc",
56-
"t4": "abc",
57-
"t5": "c",
58-
"t6": ""
59-
}
60-
]
61-
```
39+
40+
This example illustrates various ways to trim a string expression.
41+
42+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/trim/query.sql" highlight="2-9":::
43+
44+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/trim/result.json":::
6245

6346
## Remarks
6447

65-
This system function will not utilize the index.
48+
- This function doesn't use the index.
6649

6750
## Next steps
6851

6952
- [System functions Azure Cosmos DB](system-functions.yml)
70-
- [Introduction to Azure Cosmos DB](../../introduction.md)
53+
- [`TRUNC`](trunc.md)

0 commit comments

Comments
 (0)