Monday, 12 February 2018

Trigger for insert in sql server


    create trigger inserts
    on srudent
    for insert as begin declare
                 @id int,
                 @name nvarchar(30),
                 @gender nvarchar(7),
                 @age int
                 select @id= id ,@name=name,@gender = gender,@age=age from inserted
                 insert into backs values('New id is '+cast(@id as nvarchar(10))+' New name is '+@name+' New gender is '+@gender+' new age is '+cast(@age as nvarchar(10))+' Date is '+cast(getDate() as nvarchar(20)))
                   end

No comments:

Post a Comment