- We
can execute a stored procedure whenever we want with the help of the exec
command, but a trigger can only be executed whenever an event (insert,
delete, and update) is fired on the table on which the trigger is defined.
- We
can call a stored procedure from inside another stored procedure but we
can't directly call another trigger within a trigger. We can only achieve
nesting of triggers in which the action (insert, delete, and update)
defined within a trigger can initiate the execution of another trigger defined
on the same table or a different table.
- Stored
procedures can be scheduled through a job to execute on a predefined time,
but we can't schedule a trigger.
- Stored the procedure can take input parameters, but we can't pass parameters as input
to a trigger.
- Stored
procedures can return values but a trigger cannot return a value.
- We
can use Print commands inside a stored procedure for debugging purposes
but we can't use print commands inside a trigger.
- We
can use transaction statements like begin the transaction, commit the transaction,
and rollback inside a stored procedure but we can't use transaction
statements inside a trigger.
- We
can call a stored procedure from the front end (.asp files, .aspx files,
.ascx files, etc.) but we can't call a trigger from these files.
- Stored
procedures are used for performing tasks. They can have parameters and return multiple result sets.
- Triggers
normally are used for auditing work. They can be used to trace the activities of table events.
Friday, December 14, 2018
Difference between a Stored Procedure and a Trigger?
Labels:
INTERVIEW QUESTION
Suriya is experienced in the IT industry, as a Software Test Engineer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment