LEN

Transact-SQL Reference

Transact-SQL Reference

LEN

Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks.

Syntax

LEN ( string_expression )

Arguments

string_expression

Is the string expression to be evaluated.

Return Types

int

Examples

This example selects the number of characters and the data in CompanyName for companies located in Finland.

USE Northwind
GO
SELECT LEN(CompanyName) AS 'Length', CompanyName
FROM Customers
WHERE Country = 'Finland'

Here is the result set:

Length       CompanyName
-----------  ------------------------------
14           Wartian Herkku
11           Wilman Kala

See Also

Data Types

String Functions