Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2005
 LEN (Transact-SQL)
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
SQL Server 2005 Books Online (November 2008)
LEN (Transact-SQL)

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

ms190329.note(en-US,SQL.90).gifNote:
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.

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 AdventureWorks;
GO
SELECT LEN(FirstName) AS Length, FirstName, LastName 
FROM Sales.vIndividualCustomer
WHERE CountryRegionName = 'Australia';
GO
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker