Search by function or task
tee / insights
LEARNING / SQLHOME
SQL / FUNCTION REFERENCE

SQL function map

Find the task. Choose the arguments. Check the result.

SQL

Explore 677 entries in 14 categories, with dialect-specific syntax, arguments, and two examples.

677 / 677 topics
Text / Snowflake

TRIM

Trim both ends

English words and abbreviations

trim = cut away the edges

What is it for?

Clean imported CSV and form values for analysis.

Return valueText

Syntax

TRIM(text[, characters])

What goes in each argument?

ArgumentType / notationExample inputMeaning / default
textRequiredVARCHAR'Ann' / nameThe text to process: a column or string literal.
charactersOptionalVARCHAR' /'Set of characters to trim; default is whitespace/space.

SQL you can run as written

Check each example’s inputs before copying it to the selected SQL engine. AS result names the output column.

Example 1 · Basic

SELECT
  TRIM('  Ann  ') AS result;

Remove the spaces from both ends of ' Ann '. Return the output in the result column.

Result of this SQL
result
Ann

Example 2 · Advanced

SELECT
  TRIM('xyxAnnxyxy', 'xy') AS result;

'xy' specifies the character set {x, y}. Remove consecutive x or y characters at both ends, leaving Ann. It does not match the substring 'xy'; characters inside the text stay unchanged. Return the output in the result column.

Result of this SQL
result
Ann

Before you use it

Snowflake defaults to ASCII spaces; BigQuery to whitespace. The second argument is a character set, not a substring.

In the other dialect BigQuery

TRIM(text[, characters])

Snowflake defaults to ASCII spaces; BigQuery to whitespace. The second argument is a character set, not a substring.

Official reference ↗