日期:2014-05-18 浏览次数:20551 次
--try create trigger geniuswjt on BZDM instead of insert,update as select @baozhuangmingcheng=baozhuangmingcheng from inserted if @baozhuangmingcheng in ('ZX','ZH') select @baozhuangdaima=banbenhao+'-'+long+'-'+wit+'-'+high+'-'+banbenhao from inserted else set @baozhuangdaima=@baozhuangmingcheng if exists(select 1 from BZDM where baozhuangdaima=@baozhuangdaima) begin print '此表中有该代码,不能新增' return end if exists(select 1 from inserted) and not exists(select 1 from deleted) insert into BZDM select @baozhuangdaima,baozhuangmingcheng,banbenha,[long],wit,high,beizhu from inserted else if exists(select 1 from inserted) and exists(select 1 from deleted) begin delete a from BZDM a,deleted b where a.baozhuangdaima=b.baozhuangdaima insert into BZDM select @baozhuangdaima,baozhuangmingcheng,banbenha,[long],wit,high,beizhu from inserted end
------解决方案--------------------
--声明下变量记得 declare @baozhuangmingcheng varchar(100) declare @baozhuangdaima varchar(100)
------解决方案--------------------