• Hugo Kornelis (2/11/2013)


    When picking my answer, I knew I had a 50/50 chance, because my mindreading skills are still not on par with my SQL skills.

    There were two options.

    1. The author knows very well what a batch is, and also knows very well that GO ends a batch. The phrasing of the question: "as 1 batch" was deliberate, as a sign that you should answer the question as if the GO lines are not there. He deliberately put them in to trap the people who just copy/paste the code.

    2. The author either doesn't know what a batch is, isn't aware what GO does, or wass not paying sufficient attention when adding that "as 1 batch" to the question. He meant that the entire code should be executed at once (allthough that is actually irrelevant, the results are the same if the batches, or evne the individual statements, are sent and executed one by one).

    In the first case, the entire batch will fail at parse and compile time, so none of the statements will actaully execute. You get an error message and nothing happens. The option "All statements will fail", though technically not 100% accurate (as there is a single failure of a whole batch, not multiple failures of incividual statements), comes close enough to be considered the correct answer.

    In the second case, the first batch will compile and execute successfully, the second batch will fail compilation and not execute, and the third batch will compile and execute successfully. The option "Only the 1st and 3rd statement will succeed but no rows will be returned", though technically not 100% accurate (as the 4th statement will also succeed), comes close enough to be considered te correct answer.

    I threw my dart to pick one of the two options, and failed. Oh well.

    +1 😀

    Execute as 1 Batch and results are combined toghether hence my result below therefore I answered as "All statements will fail". 😉

    Msg 2714, Level 16, State 6, Line 3

    There is already an object named '#TempQoD' in the database.

    (0 row(s) affected)

    :w00t:

    Regards
    ld

    Stoke-on-Trent
    United Kingdom

    If at first you don't succeed, go to the pub and drink away your current thought plan.