After Insert Trigger & Rollback

If a Stored Procedure contains an insert statement wrapped in a transaction and that transaction is rolled back in the procedure, does the after trigger still fire? Or is the trigger only called upon the commit statement?

Thanks.
AMLabelsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
to clarify:
  if the insert statement fails as such due to data type problems for example; the trigger will NOT raise.
  as soon as the insert could do it's initial job, the trigger will be raised even if the insert inserted 0 rows:
 insert into sometable select * from othertable where <condition>
  with a condition that will make that 0 rows are inserted
  -> the trigger WILL raise, but indeed with 0 rows in the "INSERTED" table (better use that than rowcount)

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if the procedure is like this:

  begin transaction
    insert into table ...
  rollback

and the table has a insert trigger, the trigger WILL fire
0
 
AMLabelsAuthor Commented:
would the rowcount from the inserted table work to identify whether the stored procedure's insert had indeed been successful?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.