Both are database objects containing blocks lof code that can be used for implementing business logic
The differences are:
1)Triggers fire automatically but they need events for that.
Procedures have to be explicitly called and then executed.
They do not need create,alter,drop,insert,delete,update.
we can also execute procedures automatically using the sp_procoption.
2))we cannot pass parameters inside the triggers,
but we can pass parameters inside stored procedures
example: if we want to display a message "error"
using a trigger: we need some DDL/DML Statement
using a procedure: NO DDL/DML is needed
Asked In: Many Interviews |