SQL SERVER中的触发器

来源:百度知道 编辑:UC知道 时间:2024/06/05 04:48:05
create trigger trstudent on student for update
as
if update(studentid)
begin
update borrowrecord set studentid=i.studentid from borrowrecord br,deleted d,inserted i where br.studentid=d.studentid
end;

if update(studentid)有什么作用?

判断是否更新了studentid字段,只有在更新了studentid字段的时候才执行update语句,否则更新了其他列是不执行此语句的

如果更新StudentID字段的话,执行级联更新语句

如果student表的studentid字段被更新,则执行begin...end之间的代码。