• 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.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/