Computers & ProgrammingBackend DevelopmentSQL

SQL LEN Function

The LEN function returns the length of the value in a text field.

Employees Table

employeeIDemployeeNameage
1000John Smith40
1001Fred White27
1002Jane Scott53
1003Samuel Williams31

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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top