Trigger support in SQL Server: does the platform provide INSTEAD OF and AFTER triggers but not BEFORE triggers?

Difficulty: Easy

Correct Answer: Correct — SQL Server supports INSTEAD OF and AFTER; no BEFORE triggers

Explanation:


Introduction / Context:
Different RDBMS engines implement different trigger types. In SQL Server, understanding which trigger kinds are available helps you implement business rules and updatable views correctly.


Given Data / Assumptions:

  • Object types: tables and views.
  • Trigger types considered: AFTER, INSTEAD OF, BEFORE.
  • Standard SQL Server behavior.


Concept / Approach:
SQL Server supports AFTER triggers on tables and INSTEAD OF triggers on both tables and views. BEFORE triggers are not part of SQL Server’s feature set (some other platforms have them). INSTEAD OF triggers are commonly used to make complex views updatable by re-routing DML to base tables.


Step-by-Step Solution:
Create AFTER trigger on a table: valid.Create INSTEAD OF trigger on a view: valid.Attempt a BEFORE trigger: results in syntax error.


Verification / Alternative check:
Check documentation or use SSMS GUI — BEFORE is not an available option; sys.triggers shows AFTER or INSTEAD_OF types only.


Why Other Options Are Wrong:
Claims that BEFORE triggers exist or that only one trigger type exists are incorrect. Compatibility level does not introduce BEFORE triggers.


Common Pitfalls:
Porting code from other databases that use BEFORE triggers without redesigning logic for SQL Server.


Final Answer:
Correct — SQL Server supports INSTEAD OF and AFTER; no BEFORE triggers

More Questions from SQL Server 2000

Discussion & Comments

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