返回列表 回复 发帖

删除已停用的客户,供应商.部门档案的SQL语句

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                              --已停用标志
不错的东西啊
学学
高手来了
楼主用心了,谢谢了
有些字段可以对应数据库字典修改 一下.
谢谢,我正在找这个东西呢
还没碰到~
貌似很不错~
老兄你是不是搞开发的呀、这么有兴趣研究SQL语句!不错不错
【用友学员维护资料】http://bbs.iufida.com/thread-18410-1-1.html
【教你得金币】http://bbs.iufida.com/thread-12377-1-1.html
【用友最全面资料集】:http://bbs.iufida.com/thread-16313-1-1.html
数据库达人啊
这个是U6的,如果需要用友通的可以找我..只需要改几个字段就行了..
楼主对SQL语句颇有研究,支持一下。希望以后能多发经典的帖子。
我也支持下,很多时候还真是需要这个啊!厉害厉害~
我也是才学的,以前没有学过..
支持收录啊
好东西,不知道对所有U8U6都适用吗?
返回列表
标题 作者 最后发表
U870常见问题 LANGJI-TIANYA02 2008-01-16
用友通维护案例 xu0762 2008-05-12
征集用友解决方案 shb696 2007-04-12
点击阅读更多关于的相关帖子