小弟在mssql中一主從表
主表中有一觸發器:
CREATE TRIGGER del_child_table ON [dbo].[Month_Check_C]
FOR DELETE
as
delete Month_Check_C1 from (select nos,id from deleted ) as a
where Month_Check_C1.sub_id=a.id 在後台刪除主表記錄OK在delphi前台用如下刪除出錯:tparent_qu.Delete;
tparent_qu.UpdateBatch();錯誤如下:
key information is insufficient or incorrent.too many rows were
affected by update
主表中有一觸發器:
CREATE TRIGGER del_child_table ON [dbo].[Month_Check_C]
FOR DELETE
as
delete Month_Check_C1 from (select nos,id from deleted ) as a
where Month_Check_C1.sub_id=a.id 在後台刪除主表記錄OK在delphi前台用如下刪除出錯:tparent_qu.Delete;
tparent_qu.UpdateBatch();錯誤如下:
key information is insufficient or incorrent.too many rows were
affected by update
表的主键嗎,有
FOR DELETE
as
delete Month_Check_C1 where Month_Check_C1.sub_id=(select id from deleted)
FOR DELETE
as
delete Month_Check_C1 where sub_id=(select id from deleted)試試!>>>>> 你的代碼: (select nos,id from deleted ) as a 有錯!
在触发器中先SELECT 出主表关连从表的字段,在删除子表。