CREATE TRIGGER TR_Calc_Value ON Enrollment AFTER INSERT, UPDATE AS
BEGIN
UPDATE E
set MonthlyPayment = (
select 0.05 * SUM(Salary)
from Family FAM
inner join Filiation F
on FAM.IDFamily= F.IDFamily
where F.IDStudent = I.IDStudent
)
from Enrollment E
inner join inserted I
on E.IDEnrollment= I.IDEnrollment