• 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