有三种建立触发器的方式写法,我们来看一下哪种正确
1.第一种方式
create trigger T
on stucou
for insert,update,delete
as
begin
update course set willnum=willnum+(select count(couno)from inserted) where couno=(select couno from inserted)
update course set willnum=willnum-(select count(couno)from deleted) where couno=(select couno from deleted)
end
注意此时的couno表中的willnum
删除stucou表中的数据
此时的couno表中的willnum为
故这种触发器正确被建立
2.第二种方式建立触发器
go
create trigger T
on stucou
for insert,update,delete
as
begin
update course set