Quantcast
Channel: Sqljunkieshare » Built-in T-SQL Functions (Updated SQL 2012))
Viewing all articles
Browse latest Browse all 7

Len() and Datalength()

$
0
0

In this post we will go through two scalar functions

Len() is one of the string functions

Datalength is one of the Data type functions

so what does Len() do , it returns(int) the number of characters of the specified string expression, excluding trailing blanks.

excluding trailing blanks is an important note to remember when using Len() function

 

 

 

– It can also be used in select, where clause

Declare

@string varchar(100)

set @string =‘sqljunkieshare’

select LEN(@string)

 select * from dept

where LEN(dept_id)> 5

 

Datalength() is data type function (size of the data)

It returns the number of bytes used to represent any expression.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now you have a clear idea of what does LEN() and DATALENTH()  scalar functions do



Viewing all articles
Browse latest Browse all 7

Trending Articles