TRIGGERS :
Triggers are one of the database objects, which performs their own operations when user performs any DML operations on specific table.
or
Triggers i a type of stored procedure that implicitly executed when user performs DML operation on the table. it will not accept any parameters.
In simple way triggers fire after DML operations (INSERT,DELETE,UPDATE) it will Executed its own operation which mentioned in trigger.
Like if we insert new records it will insert into main table and in trigger with new record
Ex: CREATE TRIGGER T1 ON EMP FOR INSERT
AS
BEGIN
INSERT INTO EMP1 SELECT *FROM INSERTED
END
It will insert the new record into emp and newly inserted record into EMP1(Trigger) like this we can know
newly inserted records in table.
Same with INSERT,DELETE,UPDATE..
TYPES OF TRIGGERS
AFTER TRIGGER
INSTEAD OF TRIGGER
After Triggers :These are the triggers, which performs their own operation after performing insert, delete, and update operations on a specific table.
syntax :
CREATE TRIGGER TRIGGERNAME ON TABLE NAME
FOR/AFTER{INSERT/UPDATE/DELETE}
AS
BEGIN
SQL STATEMENT
END
Triggers are one of the database objects, which performs their own operations when user performs any DML operations on specific table.
or
Triggers i a type of stored procedure that implicitly executed when user performs DML operation on the table. it will not accept any parameters.
In simple way triggers fire after DML operations (INSERT,DELETE,UPDATE) it will Executed its own operation which mentioned in trigger.
Like if we insert new records it will insert into main table and in trigger with new record
Ex: CREATE TRIGGER T1 ON EMP FOR INSERT
AS
BEGIN
INSERT INTO EMP1 SELECT *FROM INSERTED
END
It will insert the new record into emp and newly inserted record into EMP1(Trigger) like this we can know
newly inserted records in table.
Same with INSERT,DELETE,UPDATE..
TYPES OF TRIGGERS
AFTER TRIGGER
INSTEAD OF TRIGGER
After Triggers :These are the triggers, which performs their own operation after performing insert, delete, and update operations on a specific table.
syntax :
CREATE TRIGGER TRIGGERNAME ON TABLE NAME
FOR/AFTER{INSERT/UPDATE/DELETE}
AS
BEGIN
SQL STATEMENT
END