December 16, 2012 at 2:02 pm
Very very intesting question. Thanks Ron.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
December 16, 2012 at 3:38 pm
Been a long time since I was this happy to get a QOTD right. It wasn't that hard, but I wasn't sure of the deductive reasoning I was using. Thanks for the challenge Ron.
[font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
Connect to me on LinkedIn
December 16, 2012 at 6:12 pm
Another good QOD on a new feature of SQL 2012. Thanks, Ron.
BTW, I'm sure some of those who chose wrong answers will want to blame Microsoft for screwing up the BOL examples for TryParse(). Very strange to see that on what turns out to be an easy to understand function once you read the description.
December 16, 2012 at 9:58 pm
Very Good Question Ron!
Keep pouring more of those SS2012 stuff..
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
December 17, 2012 at 3:21 am
Thomas Abraham (12/16/2012)
Been a long time since I was this happy to get a QOTD right. It wasn't that hard, but I wasn't sure of the deductive reasoning I was using. Thanks for the challenge Ron.
+1 ... punching the air, almost like when I'd seen this weekends NFC East scores, I was. 😀
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
December 17, 2012 at 3:21 am
Hi,
Select #2 Returns 2 rows ???
I don´t think so..
Error converting string value '2013DEC32 00:00:00' into data type datetime using culture ''.
December 17, 2012 at 3:31 am
JoseACJr (12/17/2012)
Hi,Select #2 Returns 2 rows ???
I don´t think so..
Error converting string value '2013DEC32 00:00:00' into data type datetime using culture ''.
I was also quite surprised to see this answer and would have expected the SELECT to be atomic (either all or nothing). I dont have a 2012 handy so if someone could test this please?
Best Regards,
Chris Büttner
December 17, 2012 at 3:55 am
Christian Buettner-167247 (12/17/2012)
JoseACJr (12/17/2012)
Hi,Select #2 Returns 2 rows ???
I don´t think so..
Error converting string value '2013DEC32 00:00:00' into data type datetime using culture ''.
I was also quite surprised to see this answer and would have expected the SELECT to be atomic (either all or nothing). I dont have a 2012 handy so if someone could test this please?
+2
Ron, can you please remove the confusion.
December 17, 2012 at 4:57 am
Select #2 Returns 2 rows ???
I don´t think so..
Error converting string value '2013DEC32 00:00:00' into data type datetime using culture ''.
Yep - I thought that too but also do not have 2012 handy to test.
I am also looking for confirmation.
I hate getting things wrong but if I do then I want to learn something!
David Bridge
David Bridge Technology Limited
www.davidbridgetechnology.com
December 17, 2012 at 5:38 am
Mosty a good question, apart from the awful misprint - the table would not be created unless that was corrected!
To all those talking about select being atomic: that's nonsense. Select returns rows until it hits an error serious enough to make it stop. This error is serious enough, but it hits the error on the third row, when it has already returned 2 rows.
Of course this does point up another flaw in the question: the answer assumes that the select statement traverses the rows in a particular order; that is not an assumption that should be made, the data engine is free to process the rows in any order it likes, so the select could actually return 2 rows (which, with just these 3 rows in the table, it almost certainly will), or 1 row, or even no rows at all. People moan strongly about things that explicitly depend on order even when there are all sorts of checks built into the code to detect deviation from the expected order, so relying on an expected order without any checks, as does this answer, is crazy.
Tom
December 17, 2012 at 5:57 am
L' Eomot Inversé (12/17/2012)
Mosty a good question, apart from the awful misprint - the table would not be created unless that was corrected!To all those talking about select being atomic: that's nonsense. Select returns rows until it hits an error serious enough to make it stop. This error is serious enough, but it hits the error on the third row, when it has already returned 2 rows.
Of course this does point up another flaw in the question: the answer assumes that the select statement traverses the rows in a particular order; that is not an assumption that should be made, the data engine is free to process the rows in any order it likes, so the select could actually return 2 rows (which, with just these 3 rows in the table, it almost certainly will), or 1 row, or even no rows at all. People moan strongly about things that explicitly depend on order even when there are all sorts of checks built into the code to detect deviation from the expected order, so relying on an expected order without any checks, as does this answer, is crazy.
Hm :Whistling: I better get back to bed...
Now where is the internet delete button when you need it?
Best Regards,
Chris Büttner
December 17, 2012 at 6:39 am
Nice question, thanks.
December 17, 2012 at 7:00 am
Thanks for the great question Ron. I have definitely learned something today.
December 17, 2012 at 7:23 am
L' Eomot Inversé (12/17/2012)
Of course this does point up another flaw in the question: the answer assumes that the select statement traverses the rows in a particular order; that is not an assumption that should be made, the data engine is free to process the rows in any order it likes, so the select could actually return 2 rows (which, with just these 3 rows in the table, it almost certainly will), or 1 row, or even no rows at all.
I considered putting in a similar content when I answered the question, but decided to let it slide.
The ORDER BY in the queries forces the rows to be returned in the order in which they were inserted, with the third row being the error row. Without removing the ORDER BY, I have not been able to get SQL Server to return a different result set, as all things I tried ended up with a query plan where the rows were ordered first, before projecting the SELECT list.
(That being said - there is indeed no guarantee. SQL Server could come up with an execution plan that projects the SELECT list first, then reorders the rows. In that case, the second query would return no rows - sorting in an execution plan is a blocking operation, so the sort operator will not start returning rows until it has consumed the entire input, and in this hypothetic case the query would error out before the entire input has been consumed).
Viewing 15 posts - 1 through 15 (of 30 total)
You must be logged in to reply to this topic. Login to reply