SQL Flow Field Guide

TRIM

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

string transform

What changes

Input
string arguments
Output or change
string or integer
Return type
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.

Syntax at a glance

TRIM ( [ characters FROM ] string )

Work example

Remove chosen edge characters from imported or displayed text.

Use the default for ordinary spaces and spell out the character set when tabs or markers are possible.

Check your work TRIM removes characters from both ends, not matching substrings from the middle.

Practice SQL

Open in SQL Flow
SELECT TRIM('   ready   ') AS clean_label;

Open Microsoft Learn for full syntax, permissions, and details for your version.