What will happen with below code???

  • roopa.subbareddy (6/14/2015)


    There is no Single quotes in the Select for the phone number. So it must give an error message.

    Try running the code. You'll see that the integer values are silently converted to character without raising an error.


    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/

  • Hany Helmy (6/14/2015)


    Nice tricky question, thanx.

    I thought it was quite a nice question.

    It seemed pretty trick-free to me, although you did have to remember three facts: (i) that UNION is a set operation (unlike UNION ALL, which is a bag operation), (ii) that integers used in a string context are converted automatically to string, and (iii) that 1234512345 is small enough to be representable in the INT type.

    Tom

  • Easy one, thanks.

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

  • An easy one, now that I have learned the difference between UNION and UNION ALL.

Viewing 4 posts - 16 through 18 (of 18 total)

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