关于SQL Server触发器
1.在Student表中编写insert的触发器,假如每个班的学生不能超过30个,如果低于此数,添加可以完成;如果超过此数,则插入将不能实现。
2.在SC表上编写update触发器,当修改SC表中的grade字段时将其修改前后的信息保存在SC_log表中。
啦啦啦~~~大家帮帮忙啦
[解决办法]
1.必须要加触发器?个人觉得在插入之前判断下比触发器好些。
触发器:
- SQL code
create trigger to_insert on Studentinstead of insertasbegindeclare @i intselect @i = count(distinct stu_id) from Studentif @i <= 30insert into Student(...) select ... from insertedendgo