T-SQL Tutorial

T-SQL Len function


Len function

Len Example 1:

SELECT LEN ('abcde');
Result: 5

SELECT LEN ('0012345fff');
Result: 10

SELECT LEN (9870);
Result: 4

Len Example 2:

Cities table:

CITY_IDNAMESTATE
1New YorkNew York
2Los AngelesCalifornia
3ChicagoIllinois
4San AntonioTexas
5San DiegoCalifornia

SELECT City_id, Name, LEN (name) AS Result
FROM cities;

Len Result:

City_idNameResult
1New York8
2Los Angeles11
3Chicago7
4San Antonio11
5San Diego9

See also: T-SQL Functions -> Charindex -> Concat -> Left -> Lower -> Ltrim