The LENGTH function returns the number of characters in a text value in database systems that support this function. Some systems use functions such as LEN instead.
Text length checks are useful for validating data, identifying unusual values, and checking field quality.
Find customers whose names contain more than 20 characters.
SELECT
CustomerName,
LENGTH(CustomerName) AS NameLength
FROM Customers;
Length functions are useful for data validation, cleansing, identifier checks, and quality-control processes.
- LENGTH calculates text length in supported systems.
- Function names can vary between databases.
- It is useful for data-quality checks.
- It can be used in filtering.
- It can be combined with other string functions.
What does LENGTH do?
It returns the length of a text value in database systems that support the function.
Is LENGTH available with exactly the same name everywhere?
No. Some database systems use different functions, such as LEN.