• Carlo Romagnano (11/18/2010)


    Hugo Kornelis (11/17/2010)Without the reversal, the question would have been a solid test of whether people know about the dangers of using CASE in ORDER BY, and thus an excellent question. With the reversal, it's still a good question - good, not excellent.

    The QoTD was not about dangers of using CASE in ORDER BY, but the problem is in the convertion in the CASE clause.

    Hi Carlo,

    The implicit converts in the CASE are the root cause of the danger I referred to. And while the same thing may happen in a CASE anywhere, I have thus far only seen this in ORDER BY clauses. So I guess that you and I are saying the same thing, jusst using different words to describe it.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/