Len() vs datalength() in SQL Server 2005
Be careful. DATALENGTH returns the number of bytes used, not the number of characters.
Yes that's exactly what you must do. If you want to just get number of characters excluding blanks you would use LEN()
function, while in all other cases DATALENGTH()
.
Even LEN()
documentation has an information that to get number of bytes to represent the extension you should use DATALENGTH()
Here are the links to MSDN docs:
LEN()
DATALENGTH()