日期:2014-05-18 浏览次数:20426 次
create trigger t on tb for delete as inset log表 (字段列表) select 要插入的字段列表 from deleted
------解决方案--------------------
/* Table1有c1,c2两列,c1是char类型的,c2是int型的 Table2有c3,c4两列,c2是char类型的,c4是int型的 但删除Table1中的列的时候,根据c2中的数值,把Table2中c3的值等于c1值的这行的c4值减去删除掉的c2的值 */ create trigger tr_test on Table1 for delete as set nocount on update a set a.c4=a.c4-b.c4 from Table2 a inner join DELETED b on a.c3=b.c1 set nocount off go
------解决方案--------------------
你是不是在查询分析器中只执行了这一句?
update a set a.c4=a.c4-b.c4 from Table2 a inner join DELETED b on a.c3=b.c1