Triggers – Basic info

1.A trigger is a special kind of procedure that responds to specific events.

2.A Trigger is a piece of code that you attach to a particular
table.Unlike stored procedures where we have to explicitly invoke the
code , the code is trigger is automatically run whenever the events you
attached the trigger to occur in the table.

3.Indeed you can’t explicitly invoke triggers.The only way to do
this is by performing the required action in the table that they are
assigned.

4.Types of triggers. FOR | AFTER , INSTEAD OF.

5.We cannot have triggers on the tables having columns with text , ntext , image as datatype.

6.Whenever a trigger is fired internally SQL SERVER creates two
table;Inserted and Deleted.These tables are called as Magic
Tables.These magic tables are stored in temporary database.

7.The scope of the tables is only with in the trigger.

8.We cannot access these tables i.e magic tables in the trigger.Only triggers can access them.

9.Both the tables are of same structure.

10.We can use for triggers

a.Referential integrity
b.Functionality similar to a check constraint.
c.Complex view Insertion.

11.What we can attach to triggers to.
a.Insert triggers.
b.Update triggers.
c.Delete triggers.
d.Combination of above three.

I will add one more detailed article on the same topic.

Pawan Kumar
Pawankkmr@hotmail.com