Code has been added to clipboard!

Main Tips on Using the SQL Length Function

Reading time 1 min
Published Aug 9, 2017
Updated Oct 11, 2019

Web Development Course:

SQL LEN Function: Main Tips

  • This function brings back the data record value length.
  • Different databases have variously named SQL LEN functions.

Syntax of SQL LEN

SELECT LEN(col_name) FROM tbl_name;

Demo Database

In the below table there is a piece of  "Customers" table:

ID Name Contact Address City Postal_Code Country
1 Ben Choplinks Ben Choplink Obeesre Str. 51 Rome 11207 Italy
2 Donald Rich Donald Richario Avda. de la Confgfstitución 4122 Tallin 17021 Estonia
3 Lilly Smilkins Lilly Smilkin Matadsderos 2312 Eguero 14023 Mexico
4 Brandinina Tom Hitchins 110 Hanegover Sq. London WB2 2DP UK
5 Carizmos Christiano Kerrys Berguvsesvägen 9 Luleå S-968 43 Sweden

SQL LEN: Example

In the code example below we pick "Name" and "Address" columns length in the table "Customers":

SELECT CustomersName,LEN(AddressID) as LengthOfAddressID
FROM Customer;

SQLite syntax example

SELECT name, LENGTH(address) as lengthOfAddress
FROM Customers;