CHAR_LENGTH Function [String]

Returns the number of characters in a string.

Syntax

CHAR_LENGTHstring-expression )

Parameters

Parameter

Description

string-expression

The string whose length is to be calculated.

Returns

INT

Usage

Trailing white space characters are included in the length returned.

The return value of a NULL string is NULL.

If the string is in a multibyte character set, the CHAR_LENGTH value may be less than the BYTE_LENGTH value.

CHAR_LENGTH64 also supports LONG VARCHAR variables of any data size.

If you are licensed to use the Unstructured Data Analytics functionality, you can use this function with large object data. See CHAR_LENGTH Function in Unstructured Data Analytics.

Example

The following statement returns the value 8:

SELECT CHAR_LENGTH( 'Chemical' ) FROM iq_dummy

Standards and Compatibility

  • SQL—ISO/ANSI SQL compliant.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
BIT_LENGTH Function [String]
BYTE_LENGTH Function [String]
COL_LENGTH Function [System]
DATALENGTH Function [System]
LEN Function [String]
LENGTH Function [String]
OBJECT_NAME Function [System]
OCTET_LENGTH Function [String]
STR_REPLACE Function [String]