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
playstation 3 did not connect via direct proxy? can u help.
How to submit an asynchronous request to server to run a business service from a Business component script?
Should Sys Admins (Domain Admins) also have user accounts?
SQL 2005 Select Query from multiple tables
parse url in JavaScript
Need a random list of 1000 geocoded locations in any one country
PHP Cookies
Displaying GroupWise contacts in Exchange address book?
Outlook address book problem
publishing websites in TMG 2010