Predict output

  • I agree with the others here. The proffered answers were not adequate because there was too much ambiguity on what should be considered "output". If you are expecting that "output" is the result of the SELECT, then there was no correct answer. If you expected "output" to mean both messages and results, then the supposed correct answer is also not accurate.

    This question was just poorly worded. Try... Catch is a concept that is very important to understand though, so I appreciate the intent.

    Kindest Regards,Rick Farris

  • Lynn Pettis (1/20/2010)


    It isn't just the QotD that you can learn from, but also the discussion that may follow (as long as you ignore the complaints).

    Does SSC vet the questions, to a point, but not nearly as well as some people would like to see. Of all the questions I have answered, I think I only really had a serious complaint about one or two. Yes, there are issues with some of the questions, but if you look closer at the concept that the question is trying to address, and less on the question and answers themself, I think you will learn something.

    Take today's question. Based on the answers, you'd have expected there to be PRINT statements in the question but there wasn't. If you understand the concept of the TRY/CATCH, and that the divide by zero would be caught and handled in the CATCH part of the code, there really was only one answer that made sense, and it happened to be the only one with the message from the PRING statment in the CATCH block.

    I strongly disagree. I am not trying to be a jerk but this is not the first time people have complained about ambiguous answers from arup.

    What concept do new people get from incorrect answers as options? None of the answers fit at all. The fact that you assumed you knew what the author meant and selected your answer based on an assumption and not knowing proves this. What if I assumed the author missed a PRINT @i.

    I learned nothing from this except:

    -there can be mingling between result set and messages in the answer for a QoTD.

    -It is now possible for an integer field to display a string in the answer for the QoTD.

    -Ambiguity is now acceptable for listed answers to the QoTD just like irregardless is now accepted as a word by dictionaries.

  • Fatal Exception Error (1/20/2010)


    Lynn Pettis (1/20/2010)


    It isn't just the QotD that you can learn from, but also the discussion that may follow (as long as you ignore the complaints).

    Does SSC vet the questions, to a point, but not nearly as well as some people would like to see. Of all the questions I have answered, I think I only really had a serious complaint about one or two. Yes, there are issues with some of the questions, but if you look closer at the concept that the question is trying to address, and less on the question and answers themself, I think you will learn something.

    Take today's question. Based on the answers, you'd have expected there to be PRINT statements in the question but there wasn't. If you understand the concept of the TRY/CATCH, and that the divide by zero would be caught and handled in the CATCH part of the code, there really was only one answer that made sense, and it happened to be the only one with the message from the PRING statment in the CATCH block.

    I strongly disagree. I am not trying to be a jerk but this is not the first time people have complained about ambiguous answers from arup.

    What concept do new people get from incorrect answers as options? None of the answers fit at all. The fact that you assumed you knew what the author meant and selected your answer based on an assumption and not knowing proves this. What if I assumed the author missed a PRINT @i.

    I learned nothing from this except:

    -there can be mingling between result set and messages in the answer for a QoTD.

    -It is now possible for an integer field to display a string in the answer for the QoTD.

    -Ambiguity is now acceptable for listed answers to the QoTD just like irregardless is now accepted as a word by dictionaries.

    Okay. I'll shut up now.

  • Just so you know, Lynn, I appreciate your insights, especially on items such as the QotD.

    I did find the answers a little ambiguous, but I learned a bit more about analysis.

    Thanks.

    Kevin C.

  • Lynn Pettis (1/20/2010)


    mzz3lh (1/20/2010)


    I have to agree here. None of the answers match what I would expect, which would be 'This is an exception' in the message pane, followed by the contents of the temp table: 1, 2, 4, 5.

    However, when I ran this to try it out, I got an error:

    (1 row(s) affected)

    (1 row(s) affected)

    this is an exception

    Msg 208, Level 16, State 0, Line 10

    Invalid object name '#temp'.

    Which indicates that despite the try-catch block, the error caused the temp table to be dropped mid-execution.

    Or that something was wrong with the code you ran. It ran fine for me, and it appears from a few other posts that it ran fine for others.

    I agree, the answers may not have been displayed as many of us have seen it when we ran the code. The question is, were you able to correctly predict the output? In this case, as mentioned in another post, there really was only one option that could be correct. It may have been more difficult had there been one or two more possible answers with the exception message included.

    Agreed here, there is only one answer that supplies both pieces of the answer. All other answers were invalid.

    Settings in your SSMS would cause slightly different output. One scenario includes set nocount, and whether or not it is on or off.

    set nocount on gives me the following in the message pane:

    this is an exception

    set nocount off gives the following

    (1 row(s) affected)

    (1 row(s) affected)

    this is an exception

    (1 row(s) affected)

    (1 row(s) affected)

    (4 row(s) affected)

    I think being overly picky about the presentation of the available answer in this scenario is going beyond what the question was trying to derive.

    We have been shown that both parts of the correct answer are only available in one of the answers.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Agreed, Jason. The intent of the question was good and purposeful, no doubt.

    Funny that most of us, as technologists, are so insistent on a perfectly valid scenario. 🙂 The point wasn't lost on me, but I am adamant about well thought-out surveys. I remain left to wonder, for example, how much thought went into this question and for what reasons. This is and will be my main reason for engaging in this discussion, as has been my practice in prior discussions.

    Kindest Regards,Rick Farris

  • Nice QoTD :-).

    An important point to remember is that a TRY..CATCH can be used to catch all database errors having the error number >10 that do not terminate a database connection.

    MSDN has more information on this.

    http://msdn.microsoft.com/en-us/library/ms175976.aspx

  • Apart from that, what's going on with the transaction? Nobody's mentioned that, but isn't that kind of weird? (Don't shoot me if it's obvious, I'm primarily a .Net guy rather than a DBA, so Try . . .Catch was familiar ground; but that rollback in the middle - can you do that?)

  • that's because the 'correct' answer wasn't correct.

  • pg53 (1/21/2010)


    Apart from that, what's going on with the transaction? ... that rollback in the middle - can you do that?

    You can roll back a transaction in the middle, in the end, or even in the beginning of a batch – it's no problem with that 🙂

  • I too, like most others, initially felt inclined to believe none of the answers was PERFECTLY CORRECT because the text - in the middle of the answer set - was a bit misleading - mainly because everyone expected the OUTPUT to come from the select * from #temp, which could not "emit" the output displayed in the answer choices.

    However, I chose the right answer because there didn't seem to be any other answer coming close. The "right answer" had all the ingredients though not exactly in the 'proper way'.

    I see both sides of the argument - one asserting that "There is no correct answer" and the other inviting us to focus on the "larger picture".

    My only submission is for us to be a little more considerate for the poster. Someone has spent some time and effort creating the question. Creating is not an easy business and I quite liked the frankness displayed by another poster on the forum who openly accepted he wasn't quite wired for doing such a thing. Let's be a little considerate, folks. Let's also keep in mind that even those posting the questions may not be experts at creating questions. I don't think we have folks dedicated here to proof-read questions thoroughly before the questions are printed. If we are so irked by "inappropriate/incorrect" question why don't we form a volunteer group (on a revolving basis maybe) who would do the needful.

    Somebody brought GRE type questions into the picture which was again very surprising. This is a forum for learning and sharing. Let's give kudos and help make this forum a great learning experience for everyone.

    If anything - pure criticism without being properly backed by a plan of action to fix the source of criticism is a sheer waste of time IMHO.

    Regards

    Saurabh

    Saurabh Dwivedy
    ___________________________________________________________

    My Blog: http://tinyurl.com/dwivedys

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537

    Be Happy!
  • Hi,

    The CATCH clause in SQL server does exactly what a catch(Exception ex) in C# does. Also the ROLLBACK is perfectly valid; imagine what would happen if there was no TRY.. CATCH within the given sample code. In that case after opening a transaction, there would be a divide by zero error and this is analogous to an error in the transaction which would eventually result in it's roll back.

  • Saurabh Dwivedy (1/21/2010)


    <snip>

    My only submission is for us to be a little more considerate for the poster. Someone has spent some time and effort creating the question. Creating is not an easy business and I quite liked the frankness displayed by another poster on the forum who openly accepted he wasn't quite wired for doing such a thing. Let's be a little considerate, folks. Let's also keep in mind that even those posting the questions may not be experts at creating questions.

    <snip>

    Regards

    Saurabh

    Hear hear!

    Kelsey Thornton
    MBCS CITP

  • Learnt some thing . But does'nt Set ansi_warning have an impact.

    "Keep Trying"

  • Output answer should be

    1

    2

    4

    5

    why this option was not there??

Viewing 15 posts - 31 through 45 (of 54 total)

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