Friday, October 08, 2010

Difference between Trigger and a Stored Procedure

  1.  when you create a trigger you have to identify event and action of your trigger but when you create stored procedure you don't identify event and action.
  2. trigger is run automatically if the event is occured but stored procedure don't run automatically but you have to run it manually 
  3. within a trigger you can call specific stored procedure but within a stored procedure you cann;t call a trigger
-----------------------------------

  • Actually triger in action which is performed automatically before or after a event occur and stored procedure is a procedure which is executed when the it is called. Stored procedure is module.
-----------------------------
  1. Triggers are implicitly called by DB itself while Stored procedure has to be manually called by user. 
  2. Stored procedure can pass the parameters which is not a case with Triggers. 
  3. While creating a Trigger triggering event n action has to be specified which isn’t a case with Stored procedure. 
  4. A Trigger can call the specific Stored procedure in it but the reverse is not true.


1 comment:

Anonymous said...

This is really useful man , I have seen this question many times in interview.

Thanks
Javin
mysql tutorial