After delete Trigger throw error:The row value(s) updated or deleted either do not make the row unique or they alter multiple rows (2 rows).

在after delete触发器中执行update语句,更新另外一个表单数据

ALTER TRIGGER [dbo].[UpdateBookOfStudentFlag]
on [dbo].[tblBookInvoiceDetail]
AFTER DELETE
AS
BEGIN

update BookOfStudent set flag_orderUsed=0 where BookOfStudent.id = 52812--(select Book_ofStudent_Id from deleted)

END

表错,提示受影响的行数多于1

The row value(s) updated or deleted either do not make the row unique or they alter multiple rows (2 rows).

简单地在触发器中设置

SET NOCOUNT ON即可

ALTER TRIGGER [dbo].[UpdateBookOfStudentFlag]
on [dbo].[tblBookInvoiceDetail]
AFTER DELETE
AS
BEGIN
SET NOCOUNT ON
update BookOfStudent set flag_orderUsed=0 where BookOfStudent.id = 52812--(select Book_ofStudent_Id from deleted)
SET NOCOUNT OFF
END

原文地址:https://www.cnblogs.com/zyip/p/2827639.html