表上的更新触发器如下所示。
CREATE trigger [HumanResources].[tr_update_department]
on [HumanResources].[Department]
for update
as
begin
insert into HumanResources.tbl_Department_audit
select * from deleted;
end
GO
我基本上在审计表中查找名为tbl_Department_audit
的更新行信息。
每当我更新Department
表中的单个行时,我都测试了触发器,
具有更新前和更新行信息的two
行插入到tbl_Department_audit中。
我期望在更新数据之前或更新数据之后仅审核一行,而不是两者。
答案 0 :(得分:0)
请将触发器脚本更改为
CREATE trigger [HumanResources].[tr_update_department]
on [HumanResources].[Department]
after update
as
begin
insert into HumanResources.tbl_Department_audit
select * from deleted;
end
GO
更新完成后,只应插入一条记录。