Wednesday 16 October 2013

01. The management of AdventureWorks Incorporation wants that whenever the pay rate of an employee is modified, its effect on the monthly salary of that employee should be displayed. John, the Database Developer at AdventureWorks, has been asked to resolve this problem. Help John to find an appropriate solution.

create Trigger uptrigger
on HumanResources.EmployeePayHistory for UPdate
as
Begin
declare @rate as money
Declare @frq as int
select @rate=Rate,
@frq=payfrequency from Inserted
select @rate*@frq*30 as 'Monthly salary'
end

Update HumanResources.EmployeePayHistory
set rate=rate+5
Where EmployeeID=160

No comments:

Post a Comment