August 20, 2012 at 8:15 pm
Comments posted to this topic are about the item concatenation
August 20, 2012 at 8:16 pm
August 20, 2012 at 9:52 pm
Good question:-)
Its always wonderfu to brush up our fundamentals 😀
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
August 21, 2012 at 1:10 am
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.
August 21, 2012 at 1:33 am
Good question. More learning for me.
August 21, 2012 at 2:40 am
This was removed by the editor as SPAM
August 21, 2012 at 2:55 am
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.
August 21, 2012 at 2:59 am
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]
August 21, 2012 at 4:05 am
Good question. Need to remember the basics.
August 21, 2012 at 4:06 am
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.
August 21, 2012 at 6:09 am
Thanks for the question. I ran in to a similar situation while creating a query last week.
August 21, 2012 at 6:31 am
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.
August 21, 2012 at 7:02 am
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}}.
August 21, 2012 at 7:28 am
Good question..! I m woundering why almost 50% attempts are wrong.
Best,
Naseer Ahmad
SQL Server DBA
August 21, 2012 at 7:30 am
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