SQL Server Triggers — AFTER Timing What is the SQL Server trigger type that executes only after the referenced INSERT, UPDATE, or DELETE has successfully completed?

Difficulty: Easy

Correct Answer: AFTER trigger.

Explanation:


Introduction:
AFTER triggers are commonly used for auditing, denormalized updates, and enforcing post-conditions once a DML operation has succeeded. Differentiating them from INSTEAD OF triggers is vital for correct design.


Given Data / Assumptions:

  • SQL Server supports AFTER and INSTEAD OF DML triggers.
  • BEFORE timing is not available in SQL Server.


Concept / Approach:
An AFTER trigger runs after the base DML completes. The inserted and deleted pseudo-tables contain the final row versions, enabling audit and business rule checks that rely on successful persistence.


Step-by-Step Solution:
1) Determine whether the trigger runs before, after, or instead of DML.2) AFTER matches the requirement ”after the SQL command has been processed”.3) Select AFTER trigger.


Verification / Alternative check:
Create an AFTER UPDATE trigger and verify it fires only when the update succeeds and is not rolled back in compilation.


Why Other Options Are Wrong:

  • INSTEAD OF: Replaces the base DML, does not run after it.
  • BEFORE: Not supported.
  • BEGIN / QUEUE trigger: Not valid SQL Server trigger types.


Common Pitfalls:
Expecting a BEFORE trigger timing like Oracle or PostgreSQL; SQL Server provides INSTEAD OF for pre-logic.


Final Answer:
AFTER trigger.

More Questions from SQL Server 2000

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion