Hello all,
Here is the situation, I want to create a trigger so that whenever a field gets updated say salary is increased by £2000, i want it to record a history that there was a £2000 increase, be it one record update or multiple records.
Here is what I currently have as my code:
The above code records the value that was on the last record it processed i.e record had £15000 it will record £15000 instead of it sayingCode:ALTER TRIGGER [dbo].[Audit_Update] On [dbo].[tblEmployee] FOR UPDATE AS DECLARE @notes VARCHAR(200); DECLARE @DELTA MONEY; SELECT @DELTA = e.Salary From tblEmployee e SET @Notes='SALARIES UPDATED' IF UPDATE(Salary) INSERT INTO TBL_EMP_AUDIT (notes, delta) VALUES (@Notes, @Delta)
'£5000'.
Thanks in advance,





Reply With Quote