How many Records Will Get Selected

  • Malleswarareddy - No offense intended, but maybe you could try a translator, your English is not understandable. //translate.google.com/?hl=en#hi|en|

  • I'm not too sure this was really a bad question. We've seen questions receive a lot more positive feedback that were only worth 1 point. So if this was such a bad question why was it worth 3 points? Do you think certification tests have syntax errors in any of the questions?

    Dave

  • Very poor question... when it is proper to try an trick someone to test their knowledge? If you are going to test, then make the correct answer part of the question.

    Raymond Laubert
    Exceptional DBA of 2009 Finalist
    MCT, MCDBA, MCITP:SQL 2005 Admin,
    MCSE, OCP:10g

  • So will future "questions of the day" just be proofreading? Find the misspelled word! I think of questions of the day as testing knowledge of concepts, not spellchecks. I know it can't be easy getting a decent question every day, but this seems like a stretch.

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • No matter if it's a bad question or a trick question. The answer is one. The question was "How many records are returned from the last SELECT?". That answer is 1 not 3. No matter if you execute the steps as one batch or individually the select statement returns one row.

  • Toreador (6/11/2010)


    Well I learnt something, though probably not what was intended.

    Believe it or not, I never realised that identity columns are ignored if you could insert into a table using that syntax, ie not giving a column list. I've always coded such things as

    insert into MyTable (mainvalue) values (-1)

    on the assumption that otherwise it would give an error about fewer values than columns!

    I consider this good practice. Your intentions are clear. The way the question was written works, but it is much harder to read. To me it is good to be specific like this. I put this up there with calling an SP by qualifying its schema. dbo.StoredProc is much better than StoredProc. These things work, but I would rather wear out my fingers by typing a few extra characters and be clear than leave things open to ambiguous interpretation.

  • Toreador (6/11/2010)


    Well I learnt something, though probably not what was intended.

    (snip)

    That is my conclusion exactly after getting the question wrong for the wrong reason - I thought that the first insert would throw an error, thereby causing the batch to fail. So it was a good question in the sense that it showed me I need to know more SQL to work through the code in my head. Anyone can benefit from that. And the category of the question is SQL, broad enough to cover all the things people thought the question was testing.

    Having said that, it clearly seems like a trick question to me, based on the answer choices. The question can't have the actual constraint error, or else it would tip off readers about the source of the problem. So the fact that the constraint error isn't a choice, in retrospect, means the question had a trick to it.

    I'm OK with having learned that even though I paused at the constraint definition, thinking, "There's something odd about that," I am not confident enough in my SQL knowledge to have extrapolated what would actually happen when the script runs: (1) wrong constraint syntax -> (2) error in creating constraint -> (3) no constraint to stop all 3 inserts -> (4) result is 3 rows inserted and returned in the last query.

    So I am on the fence. I obviously learned something, but I still tend no to like trick questions, and I think it is possible to have instructive questions that don't depend on tricks.

    My two cents,

    webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Heh heh! I fixed the constraint syntax not thinking that was part of the problem. That'll teach me!

  • I don't see any trick here but the only thing that returns rows is cause of " GO " statement else it would return error at create constraint statement, since table is not created, no inserts happen.

    A good question about " GO " behavior. Could be 1 point question but definitely not 3 points.

    SQL DBA.

  • If the question was aiming at showing what the behaviour is of having "GO" in a batch, then it would have made sense to add the answer "The select statement will not be executed". Because if you would have thought that the syntax error would stop the batch, then the select would not have run at the end, so it would not even have returned 0 rows.

  • michael.yother (6/11/2010)


    Heh heh! I fixed the constraint syntax not thinking that was part of the problem. That'll teach me!

    You really have to hold yourself back from reading into the authors intentions about omissions. There was a question recently that actually had an unintentional syntax error. However, most questions that have syntax errors, have them on purpose and realizing that is part of puzzling out the answer.

  • I also second guessed the intent of the question. Oh well, that's they way it goes sometimes. Still glad to have a QOD to look forward to each day.

    Thanks,

    Chad

  • cathy.baker (6/11/2010)


    No matter if it's a bad question or a trick question. The answer is one. The question was "How many records are returned from the last SELECT?". That answer is 1 not 3. No matter if you execute the steps as one batch or individually the select statement returns one row.

    Actually, I ran the code and the last SELECT statement returns 3 rows. How did you get 1 row?

    I still think the question was more worthwhile than some other commenters are giving it credit for, but I also prefer when questions don't rely too much on a trick. I suppose the best advice is from those who caution against reading into the question author's intention and just step through the problem doing their best to simulate what will actually happen when the code runs.

    -webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • webrunner (6/11/2010)


    cathy.baker (6/11/2010)


    No matter if it's a bad question or a trick question. The answer is one. The question was "How many records are returned from the last SELECT?". That answer is 1 not 3. No matter if you execute the steps as one batch or individually the select statement returns one row.

    Actually, I ran the code and the last SELECT statement returns 3 rows. How did you get 1 row?

    I still think the question was more worthwhile than some other commenters are giving it credit for, but I also prefer when questions don't rely too much on a trick. I suppose the best advice is from those who caution against reading into the question author's intention and just step through the problem doing their best to simulate what will actually happen when the code runs.

    -webrunner

    How about this for this type of questions :

    Take a screenshot of the script then put the question category in syntax.

    Absoluetely no room for confusion here.

  • I just assumed they typed in the syntax incorrectly, so I corrected it for them, and got the answer wrong.

    I've seen other times where the syntax was incorrect, and you had to correct it in order to get the answer right.

    It should be 1 way or the other.

    Amy

Viewing 15 posts - 16 through 30 (of 75 total)

You must be logged in to reply to this topic. Login to reply