I used an Update statement inside a procedure to update a table which has an update trigger. Does the update statement complete after the trigger completes or what?
+2
A:
the trigger runs as part of the UPDATE statement (after the data in the table has been updated); the proc resumes after this. There are also "instead of" triggers that replace the UPDATE statement.
See here for more.
Marc Gravell
2009-02-07 13:29:56
+2
A:
There are two types of triggers in SQL Servers. INSTEAD OF triggers, and AFTER triggers. By default, a trigger is an AFTER trigger, meaning this is what happens. Consider TableA, with an UPDATE AFTER TRIGGER which updates TableB.
- Issue statement: UPDATE TableA set XXX = 5;
- TableA gets updated
- The trigger fires, and TableB gets updated.
Dave Markle
2009-02-07 13:31:13
A:
triggers are attached to the statement(s) that trigger them and are implicitly the part of transaction that fired them.
For ex :
if triggers are fired because of update , then it helps to understand that database would implicitly insert a begin tran and end tran surrounding that update.
Learning
2009-02-08 06:45:20