--只是更新? CREATE TRIGGER trg_u_行政部门名称 ON [dbo].[行政部门表] 
FOR UPDATE
AS 
if update(行政部门名称)
begin
select 行政部门名称,id=identity(int,1,1) into #i from inserted
select 行政部门名称,id=identity(int,1,1) into #d from deleted
  
update 职员表 set 行政部门名称=i_行政部门名称
from 职员表 a join(
select i_行政部门名称=i.行政部门名称,d_行政部门名称=d.行政部门名称
from #i i join #d d on i.id=d.id
)b on a.行政部门名称=b.d_行政部门名称
end

解决方案 »

  1.   

    --插入同步
    CREATE TRIGGER trg_u_行政部门名称 ON [dbo].[行政部门表] 
    FOR insert
    AS 
    insert 职员表(行政部门名称) select 行政部门名称 form inserted
    go--删除同步
    CREATE TRIGGER trg_u_行政部门名称 ON [dbo].[行政部门表] 
    FOR insert
    AS 
    delete 职员表
    from 职员表 a join deleted b on a.行政部门名称=b.行政部门名称
    go