SQL Server: Difference Between LEN and DATALENGTH

So what exactly is the difference between the LEN and DATALENGTH functions in SQL Server? They sound similar but they're actually used for two different purposes.
  • The LEN function tells you how many characters are in a string but will exclude any trailing blanks.
  • The DATALENGTH function tells you how many bytes are used to represent an expression.
This means that two string expressions, one with some trailing blanks and one without, could have the same value of LEN but different values for DATALENGTH.

0 comments:

Post a Comment