SQL Flow Field Guide

RTRIM

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 the end of a character_expression. Returns NULL if input

Syntax at a glance

RTRIM ( character_expression )

Work example

Remove trailing spaces or selected characters from text.

Test Unicode, trailing spaces, collation, empty input, and maximum output length.

Check your work Check whether trailing spaces carry meaning in identifiers or source values.

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