Len() vs Datalength() in SQL Server.


Len() function returns number of characters in the input string.
Datalength() function returns number of bytes in the input string.

Example :

Declare @Str Nvarchar(50)
Set @Str = 'Hitesh Kumar' 
Select Len(@Str) As [Len]
Select DATALENGTH(@Str) As [DataLength]


Output :
12 and 24