I\'m having trouble understanding the difference between a stored procedure and a trigger in sql. If someone could be kind enough to explain it to me that would be great.
<
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.
(Example: create,alter,drop,insert,delete,update) .
2) 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.
3) we cannot pass parameters inside the triggers,
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