Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

That case filter Expand / Collapse
Author
Message
Posted Wednesday, July 20, 2011 2:02 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, July 10, 2014 7:17 AM
Points: 439, Visits: 151
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. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Post #1144768
Posted Wednesday, July 20, 2011 2:02 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, July 28, 2014 12:53 AM
Points: 60, Visits: 202
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
Post #1144769
Posted Wednesday, July 20, 2011 2:04 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 7:52 AM
Points: 3,866, Visits: 5,017
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”
Post #1144771
Posted Wednesday, July 20, 2011 2:19 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 8:02 AM
Points: 1,105, Visits: 298
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!
Post #1144779
Posted Wednesday, July 20, 2011 2:36 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 4:41 AM
Points: 1,178, Visits: 2,646
This was ambiguous and misleading!!!

--
Nigel
Useful Links:
How to post data/code on a forum to get the best help
The "Numbers" or "Tally" Table - Jeff Moden

Post #1144782
Posted Wednesday, July 20, 2011 2:42 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, May 19, 2014 2:44 AM
Points: 549, Visits: 1,016
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
Post #1144785
Posted Wednesday, July 20, 2011 2:49 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 8:33 AM
Points: 2,469, Visits: 2,346
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".
Post #1144789
Posted Wednesday, July 20, 2011 2:56 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:07 AM
Points: 1,714, Visits: 6,259
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.
Post #1144791
Posted Wednesday, July 20, 2011 2:56 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:54 AM
Points: 2,091, Visits: 1,695
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.
Post #1144792
Posted Wednesday, July 20, 2011 2:59 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 3:47 AM
Points: 372, Visits: 654
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
----------------------------------------
Post #1144793
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse