Menu

Showing posts with label LEN() Function. Show all posts
Showing posts with label LEN() Function. Show all posts

Friday, 14 March 2014

LEN() Function in ms sql server 2008


It is used to find the length of name (text field as EmployeeName in table[employee]).it is also count space between textfields.
 
EmployeeID
EmployeeName
1
Mayank Dixit
2
Mona
3
Purnima
4
Payal

                                                     employee

In the above table (employee), we want to return value of textfield (employeename).

Syntax

SELECT        LEN(Column_Name) AS Name_of_the_expression
FROM            table_name;

Example

SELECT        LEN(EmployeeName) AS Length_of_employeename
FROM            Employee;

Here Length_of_employeename is a subname (alias) of column.

Output:-
Length_of_employeename
12
4
7
5