表subwxhtdd字段sc的更改,相应更改subwfhtdd1字段sc,以下触发器执行不成功,不知为何
SET ANSI_NULLS ONGO
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