Sql server: What is trigger in sql how to use

Sql server: What is trigger in sql how to use



Trigger in sql or Sql Trigger:

Trigger is a special kind of store procedure. This is accurse automatically when certain action is performed. It is a database object which is bound to a table and is executed automatically. You cannot explicitly invoke triggers. The only way to do this is by performing the requested action on the table that they are assigned to. 




There are three types of triggers. Basically triggers are classified in to two main type

  • Insert Of Trigger.
  • After Trigger.

This After Trigger run after an insert, update, or delete on table. They are not support view.
So we can say that after trigger also classified in to three types:-

  • AFTER INSERT trigger.
  • AFTER UPDATE trigger.
  • AFTER DELETE trigger.

Instead OF Trigger:


This can be use as an interceptor for anything that anyone try to do on our table or view.

Comments