TRIM()

All functions > STRING > TRIM()

Returns the string with whitespace from both ends removed.

Signatures

Returns: String with leading and trailing whitespace removed

TRIM(string: VARCHAR) → VARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to trim

Notes

  • Removes leading and trailing whitespace (spaces, tabs, line breaks, and similar)
  • Whitespace inside the string is left unchanged
  • TRIM('') is ''; if the input is NULL the result is NULL (use NULL(VARCHAR); bare NULL fails inference)

Examples

FeatureQL
SELECT
    f1 := TRIM('  hello  '), -- Trim both ends
    f2 := TRIM('	world	'), -- Trim tabs
    f3 := TRIM('  mixed   spaces  '), -- Only trim ends
    f4 := TRIM('no trim needed'), -- No whitespace to trim
    f5 := TRIM(NULL(VARCHAR)), -- NULL yields NULL
    f6 := TRIM(CONCAT(CHR(10), 'hello', CHR(10))) -- Line breaks at both ends
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHARf5 VARCHARf6 VARCHAR
helloworldmixed spacesno trim neededNULLhello

Last update at: 2026/05/26 17:22:09