USE [test] GO /****** Object: Trigger [dbo].[nameTriger] Script Date: 07.03.2016 21:09:34 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[nameTriger] ON [test].[dbo].[name] INSTEAD OF UPDATE AS BEGIN DECLARE @OldName nvarchar(10) DECLARE @oldID INT SET @OldName = (SELECT [name] FROM [test].[dbo].[name] WHERE id = @@IDENTITY); SET @oldID = (SELECT [id] FROM [test].[dbo].[name] WHERE id = @@IDENTITY ); BEGIN INSERT INTO [test].[dbo].[nameHistory] (id, name) VALUES (@oldID, @OldName) END END It works well, if one row is updated, if several, then it writes only one row to the audit table.
Please tell me what is wrong? Or you can not catch the update more than one line for one update command?
insertedold data probably need to get from the main table by id from inserted - Mike