1）批量删除商品
DELETE FROM ptype WHERE rec NOT IN (SELECT prec FROM dbo.vInOutStockTable) AND rec <>0 AND sonnum=0 AND  rec NOT IN (select prec FROM dbo.GoodsStocks) AND rec NOT IN (select prec FROM dbo.IniGoodsStocks) and rec not in (select prec from promotionbill )--清除没有库存且没有做过业务单据且没有促销的商品

2）批量删除单位
DELETE FROM dbo.btype WHERE rec NOT IN (SELECT BRec FROM dbo.vInOutStockTable ) AND rec <>0 AND sonnum=0 AND typeid<>'90000' AND typeid<>'91000' AND parid<>'90000' AND rec NOT IN (select ProviderId FROM dbo.GoodsStocks) AND rec NOT IN (select ProviderId FROM dbo.IniGoodsStocks)--删除没有做过业务单据和没有库存及期初的单位信息

3）批量删除会员
delete from vipcard where  IntegralTotal=0 and Cz00=0 and CzTotal=0 and Cz=0 and ljIntegral=0 and ChangeIntegral=0  and ID not in (Select vipcardid from vbillindex) --批量删除没有消费金额和积分，没有使用过的会员卡



---注意，执行脚本前数据备份
