concatenation

  • Comments posted to this topic are about the item concatenation

  • Nice question .. good to be reminded of the fundamentals / basic stuff ..

    Thanks

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Good question:-)

    Its always wonderfu to brush up our fundamentals 😀

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • I thought it will conevert everything to int. As the expression eveluates from right to left so from the right first plus will return 121 (120 will be converted to int) and so on and so forth.

    but unfortunately my guess is wrong.

  • Good question. More learning for me.

  • This was removed by the editor as SPAM

  • A good question (which I got wrong :(), but I think that these references better explain what's happening:

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

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

    When two operators have the same precedence (as concatenate and add do), then they are evaluated from left to right, so the first plus (concatenate) is done first. When the second plus is evaluated, data type precedence is considered and Int trumps String.

  • Yay! I like these questions I can answer in the blink of an eye... now, back to work.

    Thanks for today's question 😀

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • Good question. Need to remember the basics.

  • 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.


    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/

  • Thanks for the question. I ran in to a similar situation while creating a query last week.

  • Nice question, and a nice example showing that data type issues don't always result in an error. Implicit conversion isn't always your friend.

  • Prassad Dabbada V R (8/21/2012)


    I thought it will conevert everything to int. As the expression eveluates from right to left so from the right first plus will return 121 (120 will be converted to int) and so on and so forth.

    but unfortunately my guess is wrong.

    No, expressions evaluate from left to right.

    I got it wrong because I'm so used to shortcutting the addition of 3 numbers in my head that I for some reason thought SQL Server could do the same. Too early in the morning, not enough coffee, {{insert additional generic excuse}}.

  • Good question..! I m woundering why almost 50% attempts are wrong.

    Best,
    Naseer Ahmad
    SQL Server DBA

  • sestell1 (8/21/2012)


    Implicit conversion isn't always your friend.

    Implicit conversion isn't ever your friend!

Viewing 15 posts - 1 through 15 (of 34 total)

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