"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, December 12, 2012

LEN and DATALENGTH in SQL Server

Difference between LEN and DATALENGTH in SQL Server

Len will trim the end of the string and count the length where as  DATALENGTH just count the lenght,its doesn't trim :)

Below sample query and example
DECLARE @str VARCHAR(50)
SET @str='Arun Aravind '
SELECT LEN(@str) AS LenCount
SELECT DATALENGTH(@str) AS DataLengthCount















If u had any trouble just ask, Happy to help u :) 
Stay Tune...
Have a nice day... 'N happy Coding :)

No comments: