I want to write triggers to work with the inserted and deleted tables. I have written the trigger for inserting :
CREATE TRIGGER FILL_TABLE
ON Person FOR INSERT
AS
DECLARE @ID int
SELECT @ID = p.ID
FROM Person AS p
INNER JOIN inserted AS i ON p.ID =
i.ID
DECLARE @uName char(30);
SELECT @uName=SYSTEM_USER
INSERT tblOperationLog
Values ( @uName,'user has inserted a row with ID = '+Convert(nvarchar, @ID)+'', 'Insert', CURRENT_TIMESTAMP, getdate())
I want to write the trigger and use the deleted table just like the inserted one. but I don't know how. I want to retrieve the ID of the deleted rows to fill the second column of the tblOperationLog but I can't. Should I use the inner join in it too?