DML triggers, the inserted, deleted and "updated" tables

0

I have been using DML triggers, the inserted and deleted tables. But I can not find the way to have the same functionality after updating a table. Is there any way to do it?

    
asked by JGuerra 20.09.2017 в 00:18
source

1 answer

2

When an update operation (UPDATE) is executed, the process is similar to a delete operation followed by an insert operation, where the deleted pseudo-table is filled with rows containing the "old" data and the pseudo- The inserted table is filled with rows that contain the "new" data.

For the case you mention:

CREATE TRIGGER dbo.TriggerName
    ON dbo.TableName
    AFTER UPDATE
AS
BEGIN
    INSERT INTO dbo.Bitacora (Col1, Col2)
    SELECT i.ColA, i.ColB FROM inserted i;
END
GO
    
answered by 20.09.2017 / 00:32
source