Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Triggers

Author  Topic 

bigpimp
Starting Member

1 Post

Posted - 2010-05-10 : 11:03:11
6. 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)

Please can somebody help me out with this 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.

e.g. if five employees were given £1000 pay cuts in a single update statement, the audit table should contain one row with values delta = £-5000, notes = ‘Salaries updated’


7. How would you add a column to the audit table to hold the time of the update, without altering the trigger written in (6)?

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-05-10 : 11:12:21
Looks like homework. With homework, it's usually expected for the OP to supply the work they've done so far.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-10 : 13:05:16
look for CREATE TRIGGER explanation in books online

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -