create trigger upd_grade on Reports
for update,insert
as
update Students
set CreditHours=(select sum(CreditHours) from Courses where Cno in(
select Cno from Reports where Reports.Grade>=60 and Reports.Sno in(
select Sno from inserted)))where Students.Sno in(select Sno from inserted)
(select sum(CreditHours) from Courses where Cno in(
select Cno from Reports where Reports.Grade>=60 and Reports.Sno in(
select Sno from inserted)))
定義個參數,接收這個sum的值,然後再update。