Difficulty: Easy
Correct Answer: INSTEAD OF trigger.
Explanation:
Introduction:
SQL Server supports two trigger timings for DML: INSTEAD OF and AFTER. Knowing their semantics is crucial when enforcing complex business rules or redirecting writes to views.
Given Data / Assumptions:
Concept / Approach:
An INSTEAD OF trigger intercepts a DML statement and executes in its place. The original action does not occur unless the trigger code issues it explicitly. By contrast, an AFTER trigger fires only after the DML succeeds and is used for auditing, cascading logic, or post-conditions.
Step-by-Step Solution:
1) Identify trigger type that replaces the original statement.2) Recognize that SQL Server has no BEFORE trigger timing.3) Choose INSTEAD OF as the mechanism that runs in lieu of the DML statement.
Verification / Alternative check:
Create a view with an INSTEAD OF INSERT trigger; observe that inserts are handled by trigger logic and the base insert does not occur automatically.
Why Other Options Are Wrong:
Common Pitfalls:
Expecting Oracle-style BEFORE triggers in SQL Server, or assuming AFTER can cancel the base operation.
Final Answer:
INSTEAD OF trigger.
Discussion & Comments