October 30, 2010 at 1:28 pm
Comments posted to this topic are about the item What will the results be for the code below?
October 31, 2010 at 7:28 am
October 31, 2010 at 8:18 pm
Good Question. Explanation clears all the doubts
October 31, 2010 at 10:51 pm
Good Question with Proper Explanation. Thank u
November 1, 2010 at 5:48 am
Good question and I learnt something ๐
I wonder how many of those who got it right (70% at the moment) did so without running the script first!
November 1, 2010 at 6:27 am
Good Question & Nice Explanation. Thanks ๐
Thanks
November 1, 2010 at 6:30 am
Nice question!
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 1, 2010 at 6:49 am
Precedence, operation order, and implicit conversion. How many times have I been caught by those? Great explanation.
November 1, 2010 at 9:10 am
Great question and explanation. Reinforces the need to pay attention to detail.
Steve Jimmo
Sr DBA
โIf we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
November 1, 2010 at 10:16 am
Thanks for the comments. This was my first QotD and I was worried that my explanation might not have been clear enough. (The formatting is certainly an issue, but I don't think we can't format much, if any, in the explanation. Though I swear I had line breaks in there.)
November 1, 2010 at 10:25 am
The good thing is that I learned somethng here, and not about conversion precedence.
I answered that the intial assignment would fail as the CONVERT function seemed wrong. The third parameter, 101 in this case, is optional for converting strings to datetime but could be necessary to resolve ambiguities when some dates are presented in formats other than the db's local standard. I'd wrongly thought that the third parameter only worked for converting datetime TO a string.
November 1, 2010 at 12:46 pm
Nice QOTD.
I got it right but for different reasons. If you wanted to add an additional wrinkle try:
SELECT @Var2 = ' - ', @Var3 = CONVERT(DATETIME, '01/01/2010', 101),@Var1 = cast(@var3+5 as int);
SELECT @Var1 + @Var2 + @Var3 AS Result1;
If the perception is that this is performing date addition (e.g. Dateadd) the above expected result would be 5, not 2120-01-07 00:00:00.00.
Tim
November 1, 2010 at 1:49 pm
A very good explantation - thanks. I got it right with a bit of guesswork, but hadn't realised that the operator precedence was the key.
November 1, 2010 at 6:01 pm
Toreador (11/1/2010)
Good question and I learnt something ๐I wonder how many of those who got it right (70% at the moment) did so without running the script first!
I did ๐ .... I've got my share wrong too. :crying:
November 2, 2010 at 2:00 am
Hm, am I the only one who thinks the given answer is false?
According to it, there will be a "type conversion". But instead there is only a "type conversion error". Two different things...
Best Regards,
Chris Bรผttner
Viewing 15 posts - 1 through 15 (of 24 total)
You must be logged in to reply to this topic. Login to reply