LEN Function [String]

Takes one argument as an input of type BINARY or STRING and returns the number of characters, as defined by the database's collation sequence, of a specified string expression, excluding trailing blanks.

The result may differ from the string’s byte length for multi-byte character sets.

BINARY and VARBINARY are also allowed, in which case LEN() returns the number of bytes of the input.

LEN is an alias of LENGTH function

Syntax

LENstring_expr )

Parameters

Parameters

Parameters

Description

string_expr

The string expression to be evaluated.

Example

The following example returns the value 3152:

select len(Photo) from Productswhere ID = 500

Usage

This function is the equivalent of CHAR_LENGTH ( string_expression ).

Permissions

Any user can execute LEN.

Standards and Compatibility

  • SQL—Transact-SQL extension to ISO/ANSI SQL grammar.

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