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_ID | NAME | STATE |
---|---|---|
1 | New York | New York |
2 | Los Angeles | California |
3 | Chicago | Illinois |
4 | San Antonio | Texas |
5 | San Diego | California |
SELECT City_id, Name, LEN (name) AS Result
FROM cities;
Len Result:
City_id | Name | Result |
---|---|---|
1 | New York | 8 |
2 | Los Angeles | 11 |
3 | Chicago | 7 |
4 | San Antonio | 11 |
5 | San Diego | 9 |
See also: T-SQL Functions -> Charindex -> Concat -> Left -> Lower -> Ltrim