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

表subwxhtdd字段sc的更改,相应更改subwfhtdd1字段sc,以下触发器执行不成功,不知为何

tomhu 发布于 2015-03-16 11:49, 1130 次点击
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER           trigger [dbo].[updatesubwfhtdd1sc] on [dbo].[subwxhtdd1]
 after insert,update
 As
   Declare @son_id int,@htbh varchar(100),@kh varchar(100),@sc varchar(100),@thekh varchar(100),@ksmch varchar(100),@theksmch varchar(100),@khddh varchar(50),@thekhddh varchar(100),@thesc varchar(100)
  
  select @son_id=d.son_id,@htbh=(select htbh from wxhtdd where father_id=i.son_id),@sc=i.sc,@thesc=d.sc from inserted i,deleted d where isnull(i.subxh,'')=isnull(d.subxh,'') and isnull(i.khddh,'')=isnull(d.khddh,'')
  if @son_id>0
 begin     
  
 update subwfhtdd1 set sc=@sc where  isnull(htbh,'')=isnull(@htbh,'') and isnull(sc,'')=isnull(@thesc,'')
   
 end
   
1 回复
#2
tlliqi2015-03-18 08:14
不更改还是不执行
1