不知你要结转几个表大致思路: --1.新建表结构(复制出入库表的结构)select * into 出入库表_old from 出入库表 where 1=0--2.填充增经发生过但库存为零的数据到刚建的表: insert 出入库表_old select * from 出入库表 t where not exists(select 1 from 库存表 where 物料编码=t.物料编码)--3.删除出入库表库存为0的数据: delete 出入库表 where not exists not exists(select 1 from 库存表 where 物料编码=出入库表.物料编码)
--3.删除出入库表库存为0的数据: delete 出入库表 where not exists(select 1 from 库存表 where 物料编码=出入库表.物料编码)手误多了个not exists
--1.新建表结构(复制出入库表的结构)select * into 出入库表_old from 出入库表 where 1=0--2.填充增经发生过但库存为零的数据到刚建的表:
insert 出入库表_old select * from 出入库表 t where not exists(select 1 from 库存表 where 物料编码=t.物料编码)--3.删除出入库表库存为0的数据:
delete 出入库表 where not exists not exists(select 1 from 库存表 where 物料编码=出入库表.物料编码)
delete 出入库表 where not exists(select 1 from 库存表 where 物料编码=出入库表.物料编码)手误多了个not exists