concatenation

  • Yousaf Khan

    Ten Centuries

    Points: 1147

    Comments posted to this topic are about the item concatenation

  • Ron McCullough

    SSC Guru

    Points: 63877

    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]

  • Lokesh Vij

    SSChampion

    Points: 10836

    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

  • Prassad Dabbada V R

    Ten Centuries

    Points: 1251

    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.

  • Michael Lysons

    SSCertifiable

    Points: 6478

    Good question. More learning for me.

  • This was removed by the editor as SPAM

  • Andrew Watson-478275

    SSCarpal Tunnel

    Points: 4652

    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.

  • DugyC

    Hall of Fame

    Points: 3804

    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]

  • (Bob Brown)

    SSCrazy

    Points: 2705

    Good question. Need to remember the basics.

  • Hugo Kornelis

    SSC Guru

    Points: 64685

    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/

  • gaminik1

    Say Hey Kid

    Points: 705

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

  • sestell1

    SSChampion

    Points: 10230

    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.

  • sknox

    SSChampion

    Points: 12292

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

  • Error Handler

    Ten Centuries

    Points: 1086

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

    Best,
    Naseer Ahmad
    SQL Server DBA

  • Toreador

    SSChampion

    Points: 11257

    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 35 total)

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