How to create a trigger of Example of AFTER INSERT Trigger.

How to create a trigger of Example of AFTER INSERT Trigger


Example of AFTER INSERT Trigger:


In my past post “what is the trigger” we give the full explanation of sql Trigger. In this post we explain what is trigger and how many types of trigger in sql server. Now today we are giving to learn how to make a trigger and see the working of sql Trigger.

So for creating the trigger first create a table in sql database.

Create table emp
(
empId int,
empName varchar(50)
)




Let’s create trigger (AFTER INSERT Trigger)


Create trigger trginsert on emp
For INSERT
AS
Declare @empID int;
Declare @ empName varchar (50);

Select @empid=i.empId form insert i;
Select @empName=i.empName form insert i;
(empid,empName)value(@empid,@empName)

Comments