Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

TRIM SQL Function

Syntax

TRIM([trim_specification] [trim_characters ] FROM char_expression )

trim specification ::

LEADING

| TRAILING

| BOTH

Description

The function TRIM removes leading, trailing or both leading and trailing characters from the char_expression, that are present in trim_characters and returns the resultant string.

Example

SELECT TRIM ( LEADING 'x' FROM 'xxFairCom' )

FROM customers ;

FAIRCOM

------

FairCom

1 record selected

Details

  • If trim_specification is not specified, the function TRIM removes both the leading and trailing trim_characters from the char_expression.
  • If trim_characters are not specified, the function TRIM removes leading, trailing or both leading and trailing blank spaces from the char_expression.
  • If both trim_specification and trim_characters are not specified, the function TRIM removes both leading and trailing blank spaces from the char_expression.

Note: SQL-99 compatible

TOCIndex