编辑-这是从原始问题扩展而来的。
我需要一个触发器来将某些信息发送到要转移到另一个组的表。然而,只有在 T2 上由 C4 确定的某一类数据在更新时需要传输。
create trigger Trig on T2
after Insert, update, delete
if update(C3) --DETERMINES THAT RECORD HAS BEEN UPDATED IN A MANNER THAT NEEDS TO BE
TRANSFERRED
begin
if C4 != 9 return --DETERMINES IF RECORD NEEDS TO BE TRANSFERRED
else
insert P1 --BEGINS PUTTING INFORMATION INTO THE ABLE THAT IS TRANSFERRED
(C1, C2, C3)
select T1.C2, T1.C3, T2.C3 --INFORMATION THAT NEEDS TO BE TRANSFERRED
FROM T1, T2
WHERE T1.C1 = T2.C2 --T1.C1 IS A UNIQUE PRIMARY KEY THAT CONNECTS ROW IN T1 TO ROW
IN T2
END
GO
这是完整的测试代码。实际代码将涉及更多不同名称的列。所有表数据类型都相同。谢谢。