Microsoft
Software
Hardware
Network
Question : Write a trigger which, when the salary of any employee(s) is updated, inserts a single record into this audit table with the total amount of the change across all employees.
I had to revise my question since people think it's different.
Table TBL_EMP_AUDIT is defined as follows:
create table TBL_EMP_AUDIT
(auditid int primary key identity(1,1),
notes varchar(200),
delta money)
I need to write a trigger which, when the salary of any employee(s) is updated, inserts a single record into this audit table with the total amount of the change across all employees.
e.g. if five employees were given $1000 pay cut in a single update statement, the audit table should contain one row with values delta = -5000, notes = ‘Salaries updated’
I found a similar question about it on EE but they had set amounts that the salary will be reduced or added. It has to be variable.
Thanks for all your help in advance
Answer : Write a trigger which, when the salary of any employee(s) is updated, inserts a single record into this audit table with the total amount of the change across all employees.
Depends on your definition of delta.
Normally is is current - previous, so inserted - deleted.
It looks ok otherwise.
You may want to remove @affected_rows, since it is redundant.
Random Solutions
My Windows 7 Professional bootup is very slow
Samsung 160 G disk bad sector at 30.91%, HDD Reg. still finding bad sectors but no fix? Why?
extracting BLOBs
Best Method for Reporting on and Editing Large Amounts of Data
Xerox Scan to email issue - Gmail Google Apps Premiere
add hiddenfields in to a "total" field
SharePoint styling broken after migration (Urgent, Screenshots attached)
Script to change CD-Rom drive letter
Cloud Computing
SSIS Data extract from oracle to sql server