Export (0) Print
Expand All
5 out of 8 rated this helpful - Rate this topic

LEN (Transact-SQL)

Returns the number of characters of the specified string expression, excluding trailing blanks.

NoteNote

To return the number of bytes used to represent an expression, use the DATALENGTH function.

Topic link icon Transact-SQL Syntax Conventions


LEN ( string_expression )
string_expression

Is the string expression to be evaluated. string_expression can be a constant, variable, or column of either character or binary data.

bigint if expression is of the varchar(max), nvarchar(max) or varbinary(max) data types; otherwise, int.

The following example selects the number of characters and the data in FirstName for people located in Australia.

USE AdventureWorks2008R2;
GO
SELECT LEN(FirstName) AS Length, FirstName, LastName 
FROM Sales.vIndividualCustomer
WHERE CountryRegionName = 'Australia';
GO
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.