• Hugo Kornelis (5/5/2014)


    TomThomson (5/4/2014)


    If you use that code to try to create the trigger, the trigger will do nothing - the code is syntactically incorrect because the create trigger statement is not the first statement in the batch, so the trigger is not even created. So the correct answer is that trigger does nothing and the table is dropped.

    True. But the question was not related to whether the code succeeds. the question doesn't say "we shall run the below code", but "we shall create a trigger" and "the code is as follows". If I hand exactly that assignment with this code to a junior DBA, I expect him to run the code, see the error, make the obvious fix and run it again, because I asked him to create the trigger, not to act like a robot.

    If there had been an error in the code that could not be fixed unambiguously, I would agree with you. But in this case the error and the fix are so obvious that they don't make it impossible, or even harder, to answer the actual question.

    Oh, I agree with you. I don't think anyone who knows how the trigger works would choose the wrong answer because of this error. I just think it would be a good idea to insert the missing GO so that the syntax is correct. Awarding back points, as sometimes happens with question errors, would be a silly over-reaction for this one. I thought the emoticon at the end of my post would indicate that I didn't regard it as serious.

    Tom