CHAR_LENGTH function [String]

Returns the number of characters in a string.

Syntax
CHAR_LENGTH ( string-expression )
Parameters
  • string-expression   The string whose length is to be calculated.

Returns

INT

Remarks

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 value returned by the CHAR_LENGTH function may differ from the number of bytes returned by the BYTE_LENGTH function.

Note

You can use the CHAR_LENGTH function and the LENGTH function interchangeably for CHAR, VARCHAR, LONG VARCHAR, and NCHAR data types. However, you must use the LENGTH function for BINARY and bit array data types.

This function supports NCHAR inputs and/or outputs.

See also
Standards and compatibility
  • SQL/2003   Core feature.

Example

The following statement returns the value 8.

SELECT CHAR_LENGTH( 'Chemical' );