用游标,一个一个处理
场景:批量更新时 update触发器只会被update触发一次,无论更新的记录数是多少
CREATE TRIGGER [dbo].[Up_T]
ON [dbo].[T1]
FOR UPDATE
AS
begin
if update(T1_1)
BEGIN
--用游标,一个一个处理
DECLARE @fID int
DECLARE tmpGoods CURSOR for select ID from deleted
OPEN tmpGoods
FETCH NEXT FROM tmpGoods into @fID
WHILE @@FETCH_STATUS=0
BEGIN
--操作语句
update T1 set T1_2='32h4' where ID=@fID
FETCH NEXT FROM tmpGoods into @fID
END
CLOSE tmpGoods
DEALLOCATE tmpGoods
END
END
标签:触发器,END,批量,update,更新,T1,fID,tmpGoods,FETCH
From: https://www.cnblogs.com/newjersey/p/17029044.html