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

 

 

posted @ 2012-12-21 11:20  zyip  阅读(770)  评论(0编辑  收藏  举报