我使用SQL Server 2017 Management Studio。我需要trigg_1
的触发器(AFTER UPDATE
),该触发器在col_1
列中插入旧值而不是新值。我将使用新值手动更改列col_1
,触发器需要将旧值更改为col_1
。
CREATE TRIGGER trigg_1
ON table_1
AFTER UPDATE
AS
BEGIN
END
GO
尝试一下:
CREATE TRIGGER trigg_1
ON table_1
AFTER UPDATE
AS
BEGIN
UPDATE T2
SET T2.COL_1 = T1.COL_1
FROM DELETED T1
INNER JOIN TABLE_1 T2 ON T2.ID = T1.ID /* Here you must link by PK - I suggested PK contains only ID column. */
END
GO