|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 8:41 AM
Points: 374,
Visits: 124
|
|
Hello,
The question is missleading !!!
The question is "How many rows returned by executing all of the following?" , and when I executed the script the result was "(5 row(s) affected)", there is no select statement ,If you write SELECT * FROm @tbl at the end then it will return you the 5 rows. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Yesterday @ 4:09 AM
Points: 60,
Visits: 175
|
|
Hi Guys,
I agree with most comments on this question, asking us how many rows would bereturned should not have been the way to put it. As we know the answer one would get is "(5 row(s) affected)" because of the extra UNION ALL.
Also there's a huge difference between 0 Rows being returned and there being no Rows selected. In this instance the answer of 0 rows returned also becomes incorrect.
Regards, Quilz
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 3:48 AM
Points: 3,125,
Visits: 4,311
|
|
This is a question that test's reading ability and reasoning skills, more that T-SQL knowledge. In itself, a good question, with a decent explanation; just a somewhat misleading title.
This is going to get messy.....
____________________________________________ Space, the final frontier? not any more... All limits henceforth are self-imposed. “libera tute vulgaris ex”
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 8:42 AM
Points: 931,
Visits: 224
|
|
I have to agree with the dissenters. I wasn't looking for a mistake and I too decided that it was testing an insert where it was conditional on rows earlier in the insert. I did initially think that as it was only an insert then there would be no rows returned, and assumed this was a case of a misused term in the question so put 5, as the number of rows that would be returned from the select and inserted into the table.
It's ambiguous at best. It only 'tests reading and reasoning' if you're specifically looking for something to analyse. We didn't know what you were trying to do, therefore we can't know that the extra union all was unintentional.
------------------------------- Oh no!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 3:57 AM
Points: 1,163,
Visits: 2,600
|
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 9:32 AM
Points: 547,
Visits: 995
|
|
Misleading but got it right. I took a chance going with 0 as the answer is really that no rows are requested as its an Insert query, but the cloest answer to that for me, was 0 - so
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:04 AM
Points: 1,968,
Visits: 1,819
|
|
| I would replace the question "How many rows returned by executing all of the following?" in "How many rows returned by the last SELECT?" and add another answer: "None, because of no SELECT in the batch".
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:52 AM
Points: 1,356,
Visits: 4,761
|
|
My original thought was that there would be no rows returned as this was an insert. But I then thought that was silly, and I was being unfair on the questioner who had made an honest and obvious mistake - there are too many questions that provoke pedantic discussions whyen the meaning of the question is clear. So I answered the question as if it had been 'how many rows are inserted'. Given recent questions, I think this was a fair assumption to make.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 8:39 AM
Points: 1,602,
Visits: 1,084
|
|
Excellent question. I got it wrong (even after runnign the code) but there's a lesson there for all of us for whom getting things right depends on how we interpret a somewhat unclear specification.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 7:23 AM
Points: 324,
Visits: 531
|
|
Well, I think this was a useful reminder to us to actually look at the code. Yeah you might have missed a point and there's an 'incorrect' answer against your name but if you read it properly before you answer you'll get it right. I don't think this was designed to trip us up so much as to test our debugging skills, when the OP was working on his issue he would have been thinking "What's wrong with my case filter?" so why not pose that question to us? It's real-world.
If we can't so much as read a simple question properly on a simple 1-pointer, how are we expected to fully comprehend a business' requirements when we are developing some code from a functional spec etc.
From my PoV the QotD is there, not as a status symbol or as bragging points but rather to help us do our jobs better. Sometimes that means showing us things we didnt already know, sometimes asking really complicated questions and other times simply to keep us on our toes so we don't get complacent in our day to day job. As the OP states, this came from a cut and paste error - we all get those from time to time and this is a good reminder to take a step back and really look at our code when we get unintented behaviour that we can't get our heads around.
//edit - don't forget, if this question - or it's answer - was actually wrong it wouldn't have been published.
Ben
^ Thats me!
---------------------------------------- 01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010 ----------------------------------------
|
|
|
|