Len() function
This Len() function will return number of characters in the string expression excluding the trailing blanks. This mean it will right trim the blank values and give you the count of characters.
DataLength() function
This DataLength() function will return number of bytes to represent any expression. This mean it will give you a storage space required for the characters.
DECLARE @str VARCHAR(30)
SET @str='Bhavani '
SELECT LEN(@str) AS LenCount
SELECT DATALENGTH(@str) AS DataLengthCount
Example :
LenCount = 7
DataLengthCount = 10
This Len() function will return number of characters in the string expression excluding the trailing blanks. This mean it will right trim the blank values and give you the count of characters.
DataLength() function
This DataLength() function will return number of bytes to represent any expression. This mean it will give you a storage space required for the characters.
DECLARE @str VARCHAR(30)
SET @str='Bhavani '
SELECT LEN(@str) AS LenCount
SELECT DATALENGTH(@str) AS DataLengthCount
Example :
LenCount = 7
DataLengthCount = 10