--单个业务员插入 insert into 已选业务员 select * from 待选业务员 where 业务员编号 = '...'--所有业务员插入 delete from 已选业务员 insert into 已选业务员 select * from 待选业务员 --单个业务员删除 delete from 已选业务员 where 业务员编号 = '...'--所有业务员删除 delete from 已选业务员
第一个表是已选业务员表吗? 怎么与第二个表关联? 你的意思。右边已选业务 移动某到已选业务 ,然后左边的业务表,减去此业务员吗? 保持总数一样。 可使用事务,或者触发器 大致意思是 CREATE TRIGGER trigger业务 on 已选业务表 for update,insert,delete as if exists(select 1 from inserted) begin delete from 业务员,inserted where 业务员.业务员编号 =inserted.业务员编号 end else begin insert into 业务员 select * from deleted end
--是这样么? insert into 已选业务员 select * from 待选业务员 --左边 表不能有右边表的数据 select * from 用户列表 where checksum(*) not in(select checksum(*) from 等选业务员 --如果需要判断的话 需要用触发器
insert into 已选业务员 select * from 待选业务员 where 业务员编号 = '...'--所有业务员插入
delete from 已选业务员
insert into 已选业务员 select * from 待选业务员 --单个业务员删除
delete from 已选业务员 where 业务员编号 = '...'--所有业务员删除
delete from 已选业务员
怎么与第二个表关联?
你的意思。右边已选业务 移动某到已选业务 ,然后左边的业务表,减去此业务员吗?
保持总数一样。
可使用事务,或者触发器
大致意思是
CREATE TRIGGER trigger业务 on 已选业务表
for update,insert,delete
as
if exists(select 1 from inserted)
begin
delete from 业务员,inserted where 业务员.业务员编号 =inserted.业务员编号
end
else
begin
insert into 业务员 select * from deleted
end
insert into 已选业务员 select * from 待选业务员
--左边 表不能有右边表的数据
select * from 用户列表 where checksum(*) not in(select checksum(*) from 等选业务员
--如果需要判断的话 需要用触发器