Can someone please explain this:
SELECT CASE WHEN CAST(\'iX\' AS nvarchar(20)) > CAST(\'-X\' AS nvarchar(20)) THEN 1 ELSE 0 END, CASE WHEN CAS
A nice question!
Digging around, I found that the issue is related to hyphens and apostrophes. Your example exhibits the same 'odd' behaviour with '''X' as with '-X'.
I can't take credit for finding the answer, because it's here: SQL Sorting and hyphens