我使用MS SQL Management Studio 2017
。我需要trigger
(trigg_1)为AFTER UPDATE
,它要插入column
(col_1)旧值而不是新值。我将使用新值手动更改column
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