Algorithm to Create Trigger In SQL Server

In this article I describe algorithm to write trigger in SQL Server.
  • 2197

Trigger

Triggers in SQL are a special type of procedure that are executed, fired or invoked automatically in response to an action query are executed on a view or table.

Algorithm to Create Trigger In SQL Server

  1. CREATE [OR REPLACE ] TRIGGER trigger_name.
  2. {BEFORE | AFTER | INSTEAD OF }.
  3. {INSERT [OR] | UPDATE [OR] | DELETE}.
  4. [OF col_name].
  5. CREATE [OR REPLACE ] TRIGGER trigger_name.
  6. [ON table_name].
  7. [REFERENCING OLD AS o NEW AS n].
  8. [FOR EACH ROW].
  9. WHEN (condition). 

where,

trigger_name specifies the name of trigger you want to give.

before/after/instead of specifies types of trigger.

insted/update/delete specifies after which operation trigger should be fired.

table_name specifies the table name on which trigger is applied.

© 2019 DotNetHeaven. All rights reserved.