The LEN() Function The LEN() function returns the length of the value in a text field. SQL LEN() Syntax SELECT LEN(column_name) FROM table...
The LEN() Function
The LEN() function returns the length of the value in a text field.SQL LEN() Syntax
SELECT LEN(column_name) FROM table_name |
SQL LEN() Example
We have the following "Persons" table:P_Id | LastName | FirstName | Address | City |
---|---|---|---|---|
1 | Potter | Harry | Stocks55 | Tokyo |
2 | Davidson | Harley | Elvin23 | Jayanagar |
3 | Check | Peter | Marcelo | Beijieng |
Now we want to select the length of the values in the "Address" column above.
We use the following SELECT statement:
SELECT LEN(Address) as LengthOfAddress FROM Persons |
The result-set will look like this:
LengthOfAddress |
---|
8 |
7 |
6 |