Wednesday 16 October 2013

04. Create a trigger to ensure that the average of the values in the Rate column of the EmployeePayHistory table should not be more than 20 when the value of the rate is increased.

create trigger UpdatetriggerEPayHistory
on HumanResources.EmployeePayHistory
for update
as
if Update (rate)
begin
declare @AvgRate float
select @avgRate=Avg (Rate)
from HumanResources.EmployeePayHistory
if (@avgRate>20)
Begin
Print 'The averge value of rate connot be more than  20'
Rollback Transaction
end
end04.

No comments:

Post a Comment