当前位置:Gxlcms > mysql > mssql触发器代码

mssql触发器代码

时间:2021-07-01 10:21:17 帮助过:24人阅读

mssql 触发器代码

create trigger depart_update
on depart
for update
as
begin
update t set t.部门号=i.部门号 from worker t, inserted i ,deleted d where t.部门号=d.部门号
end

create trigger worker_delete
on worker
for delete
as
begin
delete t from salary t, deleted d where t.职工号=d.职工号
end


/*
在表depart上创建一个触发器depart_update,当更改部门号时同步更改worker表中对应的部门号;
在表worker上创建一个触发器worker_delete,当删除职工记录时同步删除salary表中对应职工的工资记录;

*/

人气教程排行