Learn From - Interactive SQL



SQL LEN() Function


LEN() function gets the length of the text in the specified text column of the database table.

SQL LEN() Syntax


SELECT LEN (column_name)
FROM table_name

Below is shown the "Authors" table:

FirstName LastName Address City
White Michael 22 Cleveland Av. #24 Berkeley
Hunter Sheryl NULL Salt Lake City
Smith Charlene NULL San Francisco
Jhonson Fernandis 2286 Cram Pl. #81 NULL
Robert Paul 1976 Arlington Pl. NULL

SQL LEN() Example


Text Editor below has the SQL Query, click the "View Result" button, to see the result.

To get the length of the string from the FirstName column in the Authors table.

Select LEN(FirstName) as FirstNameLength from Authors;

SQL in Text Editor: