如果A表记录被删除,B表相同关键字的记录也删除,可以:
如果数据库是SQL SERVER 则,在数据库中选择表,右键,“所有任务”-》“管理触发器”:
CREATE TRIGGER [触发器名] ON [dbo].[A] --是A表了
FOR Delete
AS --如果只有一个关键字则:
delete from B表 where 关键字 in (select 关键字 from deleted)
--如果多个关键字则:
delete from B表 where 关键字1 in (select 关键字1 from deleted) and
关键字2 in (select 关键字2 from deleted)
如果数据库是SQL SERVER 则,在数据库中选择表,右键,“所有任务”-》“管理触发器”:
CREATE TRIGGER [触发器名] ON [dbo].[A] --是A表了
FOR Delete
AS --如果只有一个关键字则:
delete from B表 where 关键字 in (select 关键字 from deleted)
--如果多个关键字则:
delete from B表 where 关键字1 in (select 关键字1 from deleted) and
关键字2 in (select 关键字2 from deleted)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货