SELECT '1' as t
UNION ALL
SELECT 'A' as t
union all
SELECT '['as t
ORDER BY t
I'd expect it to be 1, A, [ but instead it's [, 1, A [ is ascii 91 which is greater than both 1 and A, so why does it come first?
KarlWell, I can tell you that it's related to collation. And I can also tell you that this will get you the results you expect:
SELECT t FROM
(
SELECT '1' as t
UNION ALL
SELECT 'A' as t
union all
SELECT '['as t
) AS A
ORDER BY t collate SQL_Latin1_General_Cp437_BIN
But I can't tell you intelligently why that works.
Terri|||some collations would actually place a "y" towards the beginning of the alphabet...
its not always tied to the ascii codesql
No comments:
Post a Comment