Tuesday 2 April 2013

Create A trigger on table Before and after delete events

-------- Create A Trigger on table after Delete events ---------

CREATE TRIGGER trgpo on po

after delete 
as
declare @id int;
declare @name varchar(50);
select @id = d.id from deleted d;
select @name = d.name from deleted d;
insert into pohistory values (@id,@name)

go


-------- Create A Trigger on table before Delete events ---------

for delete
as
declare @id int;
declare @name varchar(50);
select @id = d.id from deleted d;
select @name = d.name from deleted d;
insert into pohistory values (@id,@name)

go

No comments:

Post a Comment