我有两个表,一个是 Products 和 Products_audit,我想像审计表一样使用 Products_audit,所以我想在更新后使用触发器。我写了触发器,但不明白如何连接两个表“已插入”和“已删除”
CREATE TRIGGER Super2
ON Products
AFTER Update
AS
BEGIN
INSERT INTO Products_audit
(ProductID,
ProductName,
SupplierID,
CategoryID,
QuantityPerUnit,
UnitPrice,
UnitsInStock,
UnitsOnOrder,
ReorderLevel,
Discontinued,
Date,
[User])
SELECT
ProductID,
ProductName,
SupplierID,
CategoryID,
QuantityPerUnit,
UnitPrice,
UnitsInStock,
UnitsOnOrder,
ReorderLevel,
Discontinued,
getdate(),
suser_sname()
FROM deleted
inserted
inner join deleted d on i.id = d.id
END
请帮我写下lastes字符串
FROM deleted
inserted
inner join deleted d on i.id = d.id
END
因为我不知道如何以正确的方式编写它们。