触发器方式: create trigger trg_A on A for update,delete as begin if exists(select 1 from inserted) update B set Name=(select Name from inserted) where Name=(select Name from deleted) else delete B where Name=(select Name from deleted) end go 要使用
级联性更
新和删除,用户可以在Alter TABLE 语句的CONSTRAINT子句中使用ON Update CASCADE 和/或 ON Delete CASCADE 关键字。注意他们都必须是应用于外键的。 级联更新和级联删除方式: Alter TABLE [dbo].[T_USERGROUP] ADD CONSTRAINT [FK_T_USERGROUP_T_ACCTTEMPLATE] FOREIGN KEY ( [ATNAME] ) REFERENCES [dbo].[T_ACCTTEMPLATE] ( [ATNAME] ) ON Update CASCADE ON Delete CASCADEcreate or replace trigger tduStudent
on aa for insert
begin
insert into bb values(aa.id,,)
end
go
我觉得是你的语法没写对,我也不太记得了
触发器很少用的,比较消耗性能;
评论列表(0条)