The LEN
function returns the length of the value in a text field.
Employees Table
employeeID | employeeName | age |
---|---|---|
1000 | John Smith | 40 |
1001 | Fred White | 27 |
1002 | Jane Scott | 53 |
1003 | Samuel Williams | 31 |
In this example, we want to find to a number of characters in each of the employees’ names.
Syntax
SELECT LEN(column_name)
FROM Table
Example
SELECT LEN(employeeName) as [Length of Name]
FROM employees
Results
Length of Name |
---|
10 |
10 |
10 |
15 |
The SQL LEN
function is used to determine the length of the text in a field.