concatenation

  • Great question, thanks!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I guess this depends on the initial type of the data which in the first position.

    Not entirely true. (Try '130' + 1 + '120' => 251)

    If you see the links I posted earlier, the key in this case is datatype precedence. It takes the operands and applies the precedence rules - in this case, the integer takes priority, regardless of whether it's first or second.

    http://msdn.microsoft.com/en-us/library/ms190276 (operator precedence)

    http://msdn.microsoft.com/en-us/library/ms190309 (data type precedence)

  • I particularly liked this question because I got it wrong but shouldn't have!

  • Hugo Kornelis (8/21/2012)


    A good question. I'll admit that I am surprised at the high number of incorrect answers; I would have expected 70 to 80 percent to get this right.

    I'm not surprised that the wrong answers are fairly evenly divided over the wrond answers; they are all very good distractors. Well done!

    And Andrew, thank you for providing the links and explanation that really explain the results; they are a good addition to the explanation and references given bij Yousaf.

    +1 - although I've noticed before that people get confused about evaluation order where operators have the same precedence, which probably accounts for some of the "251" answers.

    Tom

Viewing 4 posts - 31 through 34 (of 34 total)

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