What are the difference between data length and length in
SQL Server-2008?

Answers were Sorted based on User's Feedback



What are the difference between data length and length in SQL Server-2008?..

Answer / sapthagiri

LEN
Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks.

DATALENGTH
Returns the number of bytes used to represent any expression.

Is This Answer Correct ?    2 Yes 0 No

What are the difference between data length and length in SQL Server-2008?..

Answer / bindu

The DATALENGTH function counts both trailing spaces and preceeding spaces when calculating the length of the expression.
The DATALENGTH function will return NULL, if the expression is NULL.

The LEN function does NOT count trailing spaces at the end of the string when calculating the length of the string.
The LEN function does count spaces at the start of the string when calculating the length of the string.
The LEN function will return NULL, if the string is NULL.

Is This Answer Correct ?    2 Yes 0 No

What are the difference between data length and length in SQL Server-2008?..

Answer / rajkumar

If the string has the space before the like 
select LEN('  raj')
select dataLENgth('  raj')
Both consider the space.

but space is after the string len is not bother about space it wil be trucated.

datalenth counted with space.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL Server Interview Questions

is it possible to use a variable in a query with the IN clause (a,b,c..z), without getting quotes or conversion errors?

2 Answers  


if 3 duplicate records in table,i want to delete 2 alternating duplicate records by keeping 1 duplicate and 1 original as it is,how?

2 Answers  


on line cluster can we make if yes tell me the procedure

0 Answers   Microsoft,


What does indexation mean?

0 Answers  


How to use "begin ... End" statement structures in ms sql server?

0 Answers  






What are commonly used odbc functions in php?

0 Answers  


What are pessimistic lock and optimistic lock?

0 Answers  


Hello all, I have data like :- year amt 2004 10 2005 20 2006 30 Now i want output as:- 2004 2005 2006 10 30 60 but i have to use here group by on year.So, i need a single query within that i can find.

3 Answers  


How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?

15 Answers   Leo Technologies, Mannar Company, Synechron,


Explain logical operators in sql server?

0 Answers  


Can a database be shrunk with users active?

0 Answers  


What are scalar functions in sql?

0 Answers  


Categories