触发器添加或删除时判断字段值再触发相应事件_shijianjun5288的空间_ ...

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



郑重声明:资讯 【触发器添加或删除时判断字段值再触发相应事件_shijianjun5288的空间_ ...】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——