Triggers :-
Definition : A trigger is special type of stored procedure that automatically run when insert update and delete event fired on table.
Syntax :
Create Trigger Trigger_name
on Table_name
AFTER {INSERT, UPDATE, DELETE}
as
{
SQL Statement
}
Trigger_Name : It is required parameter that defines the name for the new trigger.
Table_Name : It is required parameter that defines the table name to which the trigger applies,
Lets us understand how we can work with triggers in SQL Server.We can do this by first creating a table named 'Employee' using the below statement.
CREATE TABLE Employee
(
Id Int Primary KEY,
Name Varchar(45)
Salary INT,
Gender Varchar(3),
Department INT
)
Next We will insert some record into this table as follow.