Recently I faced a issue when using len() in a query to find out the length of a query, len() was not counting the trailing spaces in the value. Bu
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()