SDU Tools: Calculate string length in SQL Server T-SQL
If you ask SQL Server developers how to calculate the length of a string in T-SQL, most would tell you immediately that you need to use the LEN() function. What most don’t realize though, is that it doesn’t actually work properly.
The T-SQL LEN() function ignores any trailing spaces in a string.
That’s not how a string length function should work, or how it works in most languages. So, in our free SDU Tools for developers and DBAs, we added a simple tool that works properly. It’s called StringLength.
2019-08-15