Difference between Stored Procedures and Triggers



1. Triggers can only be implemented on tables or views but
Stored Procedure in independent code that can be specific
to database.

2. Triggers are automatically run but stored procedures are
not automatically run and they have to be called explicitly
by the user.

3. we can write a stored procedure within a trigger but
cannot write a trigger within a stored procedure.

4. Trigger is attached to table or view and is fired only
when an INSERT, UPDATE, and/or DELETE occurs, while a
stored procedure executes at any time when it is called.


A stored procedure generally performs query's on one or more tables. i.e. UPDATE, INSERT, DELETE
A trigger is tied to one table and fires based on the type of trigger you use.

1 comment:

Anonymous said...

Good Explanation