I have a scalar value function that returns a varchar of data containing the ASCII unit seperator Char(31). I am using this result as part of an Order By clause and attempting to sort in ascending order.
My scalar value function returns results like the following (nonprintable character spelled out for reference)
- ABC
- ABC (CHAR(31)) DEF
- ABC (CHAR(31)) DEF (CHAR(31)) HIJ
I would expect that when I order by ascending the results would be the following:
- ABC
- ABCDEF
- ABCDEFHIJ
instead I am seeing the results as the complete opposite:
- ABCDEFHIJ
- ABCDEF
- ABC
Now I am fairly certain that this has to do with the non-printable characters, but I am not sure why. Any idea as to why that is the case?
Thanks