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.

Nothing complex. It takes a string, and returns its length in characters.

Find out more

You can see it in action in the main image above, and in the video here:

Access to SDU Tools is one of the benefits of being an SDU Insider, along with access to our other free tools and eBooks. Please just visit here for more info:

http://sdutools.sqldownunder.com

 

Leave a Reply

Your email address will not be published.