SQL Server 2022 order by bug?

  • It’s not a SQL Server 2022 bug at all, the unexpected ORDER BY results are due to collation rules, not a change or defect in the engine. The active collation determines how characters like. and are weighted during sorting, and many linguistic collations treat punctuation specially sometimes giving - precedence over. or partially ignoring punctuation in word comparisons. That’s why values like 1. and 1- or 1.w and 1-w may appear out of order. If you want predictable, code-point–based sorting, explicitly specify a binary collation e.g. ORDER BY Id COLLATE Latin1_General_BIN or choose a collation whose punctuation behavior matches your expectations.

Viewing post 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply