Tags


It is really strange that I never ran into this before, but today while developing a piece of code – I looked at the documentation of T- SQL LEN() Function carefully:

It says:  “Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks.”

Hhmmm.. I can say that I have overlooked this thing till today. And due to this reason, the below query returns the same result. Check this out:

SELECT LEN(‘ABC‘) AS WithOut_Space‘,  LEN(‘ABC    ‘) AS With_Space

I never checked or noticed that LEN does not return full length, trailing spaces. Glad I noticed it today.

Keep Learning

Subhro Saha

Advertisements