关于触发器递归死循环的问题
CREATE TRIGGER delfiled on tablename1 FOR DELETE
AS
declare @id int,@ename varchar(50),@strdrop varchar(200)
select @id=id from deleted
select @ename=ename from deleted
delete from tablename1 where fatherid=@id
set @strdrop='alter table tablename2 drop column '+@ename+''
exec (@strdrop)
这个触发器产生了死循环,怎样修改才能避免此循环,谢谢
[解决办法]
CREATE TRIGGER delfiled on tablename1 FOR DELETE AS IF @@ROWCOUNT = 0 RETURNdeclare @id int,@ename varchar(50),@strdrop varchar(200) select @id=id from deleted select @ename=ename from deleted delete from tablename1 where fatherid=@id set @strdrop= 'alter table tablename2 drop column '+@ename+ ' ' exec (@strdrop)