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?
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?
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