TRIM Function [String]

Removes leading and trailing blanks from a string.

Syntax

TRIMstring-expression )

Parameters

Parameter

Description

string-expression

The string to be trimmed.

Returns

VARCHAR

NVARCHAR

LONG VARCHAR

LONG NVARCHAR

Note: The result data type is a LONG VARCHAR. If you use TRIM in a SELECT INTO statement, you must have an Unstructured Data Analytics Option license, or use CAST and set TRIM to the correct data type and size.

Example

The following statement returns the value “chocolate” with no leading or trailing blanks.

SELECT TRIM( '   chocolate   ' ) FROM iq_dummy

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise. Use LTRIM and RTRIM instead