SQL Server sort order with nonprintable characters
问题 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