注册 登录
编程论坛 SQL Server论坛

请问如何在保存单据之前执行触发器?

arook 发布于 2010-11-22 11:17, 819 次点击
create     trigger wcmo
on [dbo].[ICStockBill]  
for insert,update                       
as
Declare @Ftrantype  int   --单据类别定义
Select  @Ftrantype=Ftrantype  from inserted   
if (@Ftrantype=28)      
begin      
update t2 set t2.fentryselfb0847=t4.fbillno  --(需要点软件的“保存“按钮才会执行更新?能否做到只要t2表有一有数据插入就更新?)   
 from inserted as t1                 
inner join icstockbillentry as t2 on t2.finterid=t1.finterid                     
inner join icmo   as t3 on t3.finterid=t2.fsourceinterid                     
inner join seorder as t4 on t4.finterid=t3.forderinterid        
return
end  


4 回复
#2
筱晓绾2010-11-22 11:38
将绑定方法自定义,然后在保存的时候重新调用绑定.
#3
cnfarer2010-11-22 19:37
在t2表上建触发器
#4
欲与天斗2010-11-23 08:41
个人同意2楼的说法
#5
arook2010-11-23 14:01
回复 2楼 筱晓绾
小弟不才,请问如何绑定?
1