Skip to content

Commit 48da8b8

Browse files
authored
Merge pull request #23567 from rwestMSFT/patch-17
TRIM: Fix public issue 7870 and refresh article
2 parents aef7a22 + 3b026dc commit 48da8b8

1 file changed

Lines changed: 30 additions & 23 deletions

File tree

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
---
22
title: "TRIM (Transact-SQL)"
3-
description: "TRIM (Transact-SQL)"
3+
description: "Removes the space character or other specified characters from the start and end of a string."
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
6-
ms.reviewer: "wiassaf"
7-
ms.date: "09/14/2021"
6+
ms.reviewer: randolphwest
7+
ms.date: 08/04/2022
88
ms.prod: sql
99
ms.prod_service: "database-engine, sql-database"
1010
ms.technology: t-sql
1111
ms.topic: reference
12-
ms.custom: ""
1312
f1_keywords:
1413
- "TRIM"
1514
- "TRIM_TSQL"
@@ -23,31 +22,37 @@ monikerRange: "= azure-sqldw-latest || = azuresqldb-current || >= sql-server-201
2322

2423
[!INCLUDE [sqlserver2017-asdb-asdbmi-asa](../../includes/applies-to-version/sqlserver2017-asdb-asdbmi-asa.md)]
2524

26-
Removes the space character `char(32)` or other specified characters from the start and end of a string.
25+
Removes the space character `char(32)` or other specified characters from the start and end of a string.
26+
27+
:::image type="icon" source="../../database-engine/configure-windows/media/topic-link.gif" border="false"::: [Transact-SQL Syntax Conventions](../language-elements/transact-sql-syntax-conventions-transact-sql.md)
2728

2829
## Syntax
2930

31+
Syntax for SQL Server and Azure SQL Database:
32+
3033
```syntaxsql
31-
-- Syntax for SQL Server and Azure SQL Database
3234
TRIM ( [ characters FROM ] string )
3335
```
3436

37+
Syntax for Azure Synapse Analytics:
38+
3539
```syntaxsql
36-
-- Syntax for Azure Synapse Analytics
3740
TRIM ( string )
3841
```
3942

4043
[!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)]
4144

4245
## Arguments
4346

44-
characters
45-
Is a literal, variable, or function call of any non-LOB character type (`nvarchar`, `varchar`, `nchar`, or `char`) containing characters that should be removed. `nvarchar(max)` and `varchar(max)` types aren't allowed.
47+
#### *characters*
48+
49+
A literal, variable, or function call of any non-LOB character type (`nvarchar`, `varchar`, `nchar`, or `char`) containing characters that should be removed. `nvarchar(max)` and `varchar(max)` types aren't allowed.
50+
51+
#### *string*
4652

47-
string
48-
Is an expression of any character type (`nvarchar`, `varchar`, `nchar`, or `char`) where characters should be removed.
53+
An expression of any character type (`nvarchar`, `varchar`, `nchar`, or `char`) where characters should be removed.
4954

50-
## Return Types
55+
## Return types
5156

5257
Returns a character expression with a type of string argument where the space character `char(32)` or other specified characters are removed from both sides. Returns `NULL` if input string is `NULL`.
5358

@@ -57,7 +62,7 @@ By default, the `TRIM` function removes the space character from both the beginn
5762

5863
## Examples
5964

60-
### A. Removes the space character from both sides of string
65+
### A. Remove the space character from both sides of string
6166

6267
The following example removes spaces from before and after the word `test`.
6368

@@ -67,11 +72,11 @@ SELECT TRIM( ' test ') AS Result;
6772

6873
[!INCLUDE[ssResult_md](../../includes/ssresult-md.md)]
6974

70-
```
75+
```output
7176
test
7277
```
7378

74-
### B. Removes specified characters from both sides of string
79+
### B. Remove specified characters from both sides of string
7580

7681
The following example removes a trailing period and spaces from before `#` and after the word `test`.
7782

@@ -80,16 +85,18 @@ SELECT TRIM( '.,! ' FROM ' # test .') AS Result;
8085
```
8186

8287
[!INCLUDE[ssResult_md](../../includes/ssresult-md.md)]
83-
```
88+
89+
```output
8490
# test
91+
8592
```
8693

87-
## See Also
94+
## See also
8895

89-
- [LEFT (Transact-SQL)](../../t-sql/functions/left-transact-sql.md)
90-
- [LTRIM (Transact-SQL)](../../t-sql/functions/ltrim-transact-sql.md)
91-
- [RIGHT (Transact-SQL)](../../t-sql/functions/right-transact-sql.md)
92-
- [RTRIM (Transact-SQL)](../../t-sql/functions/rtrim-transact-sql.md)
93-
- [STRING_SPLIT (Transact-SQL)](../../t-sql/functions/string-split-transact-sql.md)
94-
- [SUBSTRING (Transact-SQL)](../../t-sql/functions/substring-transact-sql.md)
96+
- [LEFT (Transact-SQL)](../../t-sql/functions/left-transact-sql.md)
97+
- [LTRIM (Transact-SQL)](../../t-sql/functions/ltrim-transact-sql.md)
98+
- [RIGHT (Transact-SQL)](../../t-sql/functions/right-transact-sql.md)
99+
- [RTRIM (Transact-SQL)](../../t-sql/functions/rtrim-transact-sql.md)
100+
- [STRING_SPLIT (Transact-SQL)](../../t-sql/functions/string-split-transact-sql.md)
101+
- [SUBSTRING (Transact-SQL)](../../t-sql/functions/substring-transact-sql.md)
95102
- [String Functions (Transact-SQL)](../../t-sql/functions/string-functions-transact-sql.md)

0 commit comments

Comments
 (0)