Weird SQL Server 2005 Collation difference between varchar() and nvarchar()

后端 未结 2 995
借酒劲吻你
借酒劲吻你 2021-01-19 01:19

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         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-19 02:15

    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

提交回复
热议问题