• JacekO (8/20/2009)


    Scary part is over 30% (at the time of this post) got it wrong. Many QoDs are quite tricky but this one is very basic and really not SQL specific (data type conversion or casting is an ABC of any programming language).

    Looks like a concept of code review or inspection is missing way too often...

    I'm part of that 30%. (32% by now...)

    In my case, the problem was that I spent all my energy at dissecting and understanding the nested CONVERT and CAST operations, and when I was finished I immediately answered without noticing that the result was first assigned to a variable before displaying it. Oh well.

    On a side note, the explanation is not entirely correct. It says: "which, multiplied by 0.5 gives 10 (and not 10.5) as @C is of int datatype". Better would have been to write "which, multiplied by 0.5 gives 10.5, which is then truncated to 10 as @C is of int datatype". But maybe that's a bit too nitpicky?


    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/