Did you find this useful?
Socialize it today.


SQL LEN Function

Monday, December 12, 2011

tags SQL

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 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 legth of the text in a field.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

SQL Cookbook Head First SQL: Your Brain on SQL A Learners Guide