Using DML Triggers That Include OUTPUT

You can specify the OUTPUT Clause (Transact-SQL) with an INSERT, UPDATE, or DELETE statement inside the body of a DML trigger to return rows affected by such a modification. However, if the OUTPUT clause does not specify a table variable to receive the rows by including the INTO clause, the trigger may fail to execute under these circumstances:

  • The trigger is fired as part of multiple queries inside a single transaction.
  • The trigger accesses external data.

Trigger failure causes the triggering action to fail, and the transaction within which the triggering action occurs to be rolled back.

This consideration does not apply to use of an OUTPUT clause inside an INSERT, UPDATE, or DELETE statement that causes a DML trigger to fire — only to an INSERT, UPDATE, or DELETE statement that executes inside of a DML trigger, and includes an OUTPUT clause that does not specify INTO.

Community Additions