Don't forget to GO after ALTER TRIGGER

Today I found peculiar issue while doing SQL scripts...

A couple of months ago, I did an SQL script that, among other things had an ALTER TRIGGER statement followed by an UPDATE statement. This particular trigger was supposed to add data to a history table. For some strange reason though, I was having trouble doing a particular update statement, because it was being undone. After a couple of hours, I found the cultrip: there was an update statement inside the trigger. What happened? I didn't do a GO statement between the trigger and the update statement.
(Yeah, maybe this is obvious for all the SQL gurus out there, but it was not for me. Lesson learnt. :))

No comments:

Post a Comment