SQL Course
A Trigger is a SQL procedure that initiates an action in response to an event (Insert, Delete or Update) occurs. When a new Employee is added to an Employee_Details table, new records will be created in the relevant tables such as Employee_Payroll, Employee_Time_Sheet etc.
Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.
Difference between Stored Procedure and Trigger?
Triggers get invoked automatically when the event specified in it gets fulfilled, it can't return any value.So user have no control over it's invocation.
Whereas stored procedure can be called as per application requirement and can get output parameters. stored procedure is a block of code contains sql statements. stored procedure is a precompiled block of code,which need not be compiled for every time calling.