RTRIM()

All functions > STRING > RTRIM()

Returns the string with whitespace from the right (end) removed.

Signatures

Returns: String with trailing whitespace removed

RTRIM(string: VARCHAR, [characters: VARCHAR]) → VARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to trim
charactersVARCHARNoCharacters to remove from the end (optional; default trims whitespace)

Notes

  • Removes trailing whitespace only (spaces, tabs, line breaks, and similar) when characters is omitted
  • With characters, removes trailing code points that appear in that string
  • Leading and internal whitespace are unchanged
  • RTRIM('') is ''; if the input is NULL the result is NULL (use NULL(VARCHAR); bare NULL fails inference)

Examples

FeatureQL
SELECT
    -- Trim right only
    f1 := RTRIM('  hello  '),
    -- Trim tab from right
    f2 := RTRIM('  world	'),
    -- Only right trim
    f3 := RTRIM('  mixed   spaces  '),
    -- No right whitespace
    f4 := RTRIM('no trim needed'),
    -- NULL yields NULL
    f5 := RTRIM(NULL(VARCHAR)),
    -- Trim custom characters
    f6 := RTRIM('helloxx', 'x')
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHARf5 VARCHARf6 VARCHAR
hello world mixed spacesno trim neededNULLhello

Last update at: 2026/06/20 10:08:10