bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server LEN() Function

Example

SELECT
LEN('ExampleSite.com');

Definition and Usage

The LEN() function returns the length of a string.

Note

Trailing spaces at the end of the string is not included when calculating the length. However, leading spaces at the start of the string is included when calculating the length.

Tip

Also look at the DATALENGTH() function.

Syntax

LEN(
string
)

Parameter Values

ParameterDescription
stringRequired. The string to return the length for. If string is NULL, it returns NULL

Technical Details

Works in:SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse

Previous

SQL Server LEFT() Function

Next

SQL Server LOWER() Function