hi, I need your help .
I need to log every row that is deleted from a transaction_table. so I created a trigger on the table like this:
CREATE TRIGGER TranLog_d ON [dbo].[Transactions]
FOR DELETE
AS
declare @id int , @Tran varchar(10) , @Amount numeric(18,2)
select @id = id , @Tran = Tran, @Amount = amount
from deleted
insert Tran_deleted (id, Tran, Amount) values (@id , @Tran, @Amount)
The above trigger works fine when I am deleting single row at a time, but when I delete more than one record,lets say 3 records, the last deleted record is appended to the Tran_deleted table.
Any advice how to capture all deleted rows using trigger
Thanks
Ehx
I need to log every row that is deleted from a transaction_table. so I created a trigger on the table like this:
CREATE TRIGGER TranLog_d ON [dbo].[Transactions]
FOR DELETE
AS
declare @id int , @Tran varchar(10) , @Amount numeric(18,2)
select @id = id , @Tran = Tran, @Amount = amount
from deleted
insert Tran_deleted (id, Tran, Amount) values (@id , @Tran, @Amount)
The above trigger works fine when I am deleting single row at a time, but when I delete more than one record,lets say 3 records, the last deleted record is appended to the Tran_deleted table.
Any advice how to capture all deleted rows using trigger
Thanks
Ehx