网站首页 > 服务与支持 > 常见问题

药易通删除未使用过的商品资料

2017-04-20 17:28:20 岳阳诺尔软件科技有限公司 阅读

update products set deleted=1 

where deleted=0 and child_number=0 

and  product_id not in

(select distinct a.p_id from

(

select distinct p_id from storehouseini  --期初库存

union all

select distinct p_id from storehouse     --库存

union all

select distinct p_id from storedx        --代销库存

union all

select distinct p_id from storedxini     --代销库存期初

union all

select distinct p_id from productdetail  --明细

union all

select distinct p_id from salemanagebill --销售

union all

select distinct p_id from salemanagebilldrf --销售草稿

union all

select distinct p_id from buymanagebill --采购

union all

select distinct p_id from buymanagebilldrf --采购草稿

union all

select distinct p_id from storemanagebill --库存类单据

union all

select distinct p_id from storemanagebilldrf --库存类单据草稿

union all

select distinct p_id from OrderBill  --合同

union all

select distinct p_id from TranManagebill --配送类单据

union all

select distinct p_id from TranManagebillDrf --配送类单据草稿

union all

select distinct p_id from TranBill  --请货

union all

select distinct p_id from GoodsCheckBill --盘点

union all

select distinct p_id from GoodsCheckBillDrf --盘点单草稿


) a

)


--清除价格跟踪库

delete from salepricehis where p_id in (select product_id from products where deleted=1)

delete from buypricehis  where p_id in (select product_id from products where deleted=1)


--清除productclient

delete from productbalance where p_id in (select product_id from products where deleted=1)


--清除价格库

delete from price where p_id in (select product_id from products where deleted=1)

delete from posprice where p_id in (select product_id from products where deleted=1)





岳阳诺尔软件科技有限公司 版权所有 2008-2014 湘ICP备12010268号