CHARLEN (TSQL Function)

Returns the length of a string.

Trailing blanks are not discarded.

Syntax

CHARLEN ( string_expression )

Arguments

string_expression
is a string expression of type varchar.

Return Types

Returns int.

Remarks

This function returns the full length of the string.

The similar function LEN excludes trailing blanks.

This function doesn’t exist in MS SQL Server.

Examples

PRINT LEN('guépard');
PRINT CHARLEN('guépard');
PRINT LEN('guépard      ');     -- trailing blanks are excluded
PRINT CHARLEN('guépard      '); -- trailing blanks are not excluded
PRINT LEN('');
PRINT CHARLEN('');

The result is:

7
7
7    <--- LEN() excludes trailing blanks
13
0
0
RSQL, a simple alternative to Microsoft SQL Server