到晚上查了一下,发现可以用两种办法
触发器方式:
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 [dbo].[T_USERGROUP] ADD
CONSTRAINT [FK_T_USERGROUP_T_ACCTTEMPLATE] FOREIGN KEY
(
[ATNAME]
) REFERENCES [dbo].[T_ACCTTEMPLATE] (
[ATNAME]
) ON UPDATE CASCADE ON DELETE CASCADE