|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
Delete
from Inventory
where
not exists(select * from CurrentStock
where Inventory.cInvCode=CurrentStock.cInvCode) --现存量表
and not exists(select * from IA_Subsidiary
where Inventory.cInvCode=IA_Subsidiary.cInvCode) --发票表
and not exists(select * from RdRecords
where Inventory.cInvCode=RdRecords.cInvCode) --收发货记录表
and not exists(select * from pursettlevouchs
where Inventory.cInvCode=pursettlevouchs.cInvCode) --采购结算单子表
and not exists(select * from sa_invuprice
where Inventory.cInvCode=sa_invuprice.cInvCode) --销售报价表
and not exists(select * from Dispatchlists
where Inventory.cInvCode=Dispatchlists.cInvCode) --发货单列表
and not exists(select * from ProductStructuresEx
where Inventory.cInvCode=ProductStructuresEx.cPSPCode) --产品结构母产品
and not exists(select * from ProductStructuresEx
where Inventory.cInvCode=ProductStructuresEx.cPSCode) --产品结构子产品
and not exists(select * from PriceJustify
where Inventory.cInvCode=PriceJustify.cInvCode) --销售调价记录表
and not exists(select * from SO_SODetails
where Inventory.cInvCode=SO_SODetails.cInvCode) --销售订单子表
and not exists(select * from PurBillVouchs
where Inventory.cInvCode=PurBillVouchs.cInvCode) --采购发票子表
and dEDate is not null --已停用产品
--=======================================删除停用的客户档案
Delete
from customer
where
not exists(select * from Dispatchlist
where customer.cCusCode=Dispatchlist.cCusCode) --发货单列表
and not exists(select * from gl_accass
where customer.cCusCode=gl_accass.ccus_id) --辅助总账
and not exists(select * from GL_accvouch
where customer.cCusCode=GL_accvouch.ccus_id) --凭证及明细账
and not exists(select * from SO_SOmain
where customer.cCusCode=SO_SOmain.cCusCode) --销售订单主表
and not exists(select * from SA_QuoDetails
where customer.cCusCode=SA_QuoDetails.cCusCode) --销售报价表
and dEndDate is not null --已停用标志
---------------------s---o---f----t----b---b----s----.-----n---e---t----------------------
----------================================删除停用的供应商档案
Delete
from Vendor
where
not exists(select * from po_pomain
where Vendor.cvencode=po_pomain.cvencode) --采购订单主表
and not exists(select * from gl_accass
where Vendor.cvencode=gl_accass.csup_id) --辅助总账
and not exists(select * from GL_accvouch
where Vendor.cvencode=GL_accvouch.csup_id) --凭证及明细账
and not exists(select * from RdRecord
where Vendor.cvencode=RdRecord.cvencode) --收发货记录表
and not exists(select * from Ven_Inv_Price_Rule
where Vendor.cvencode=Ven_Inv_Price_Rule.cvencode) --供应商报价
and dEndDate is not null --已停用标志 |
|