create trigger addassetssum
on assets for insert
as
begin
declare @fla int
select @fla=flag from inserted
if(@fla=0)
begin
update assetssum set flag0=flag0+1
end
else if(@fla=1)
begin
update assetssum set flag1=flag1+1
end
else if(@fla=2)
begin
update assetssum set flag2=flag2+1
end
else if(@fla=3)
begin
update assetssum set flag3=flag3+1
end
end
create trigger delassetssum
on assets for delete
as
begin
declare @fla int
select @fla=flag from deleted
if(@fla=0)
begin
update assetssum set flag0=flag0-1
end
else if(@fla=1)
begin
update assetssum set flag1=flag1-1
end
else if(@fla=2)
begin
update assetssum set flag2=flag2-1
end
else if(@fla=3)
begin
update assetssum set flag3=flag3-1
end
end