我有一个看起来像这样的触发器:
ALTER TRIGGER [dbo].[trSeasonHotelsSupplierOfferUpdate]
ON [dbo].[SeasonHotelsSupplierOffers]
AFTER UPDATE
AS
BEGIN
IF ((SELECT COUNT(*) FROM inserted) = 1 AND (SELECT COUNT(*) FROM deleted) = 1)
BEGIN
INSERT INTO SeasonHotelsSupplierOffersHistory (SeasonHotelSupplierOfferID, ColumnEN, OldValue, NewValue, UpdateDate, UpdatedByID)
SELECT
i.SeasonHotelSupplierOfferID, 'Name', d.Name, i.Name, i.UpdateDate, i.UpdatedByID
FROM
inserted i, deleted d
WHERE
ISNULL(i.Name,'')<>ISNULL(d.Name,'')
END
END
我也需要对插入的数据和删除的数据进行这项工作。这一切都保存到一个名为 SeasonHotelsSupplierOffersHistory 的表中,该表具有以下列:
SeasonHotelSupplierOfferID、ColumnEN、OldValue、NewValue、UpdateDate、UpdateByID
我知道我必须说更新后,删除,插入`,但仅此而已。
谢谢