TA的每日心情 | 奋斗 2014-8-29 14:48 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
发表于 2011-4-6 13:14:19
|
显示全部楼层
备份好帐 反结帐,反初始化 到查询分析器中执行以下语句
exec sp_cleanitemdetailv
update a set a.fdetailcount=b.Fcount from t_itemdetail a join (select Fdetailid,count(Fitemid) Fcount from t_itemdetailv where fitemid<>0 group by Fdetailid) b on a.fdetailid=b.fdetailid
exec sp_cleanitemdetailv
update t_account set Fdetailid =(select min(fdetailid) from t_itemdetail where fdetailid in (select Fdetailid from t_itemdetailv where fitemid=-1) and Fdetailcount=1 and F2=-1 ) where Fdetailid in (select (fdetailid) from t_itemdetail where fdetailid in (select Fdetailid from t_itemdetailv where fitemid=-1) and Fdetailcount=1 and F2=-1 )
delete from t_itemdetail where Fdetailid in(select (fdetailid) from t_itemdetail where fdetailid in (select Fdetailid from t_itemdetailv where fitemid=-1) and Fdetailcount=1 and F2=-1 ) and Fdetailid <>(select min(fdetailid) from t_itemdetail where fdetailid in (select Fdetailid from t_itemdetailv where fitemid=-1)and Fdetailcount=1 and F2=-1 ) exec sp_cleanitemdetailv
select * from t_balance where fdetailid not in (select fdetailid from t_itemdetail)
delete from t_balance where fdetailid not in (select fdetailid from t_itemdetail)
select * from t_quantitybalance where fdetailid not in (select fdetailid from t_itemdetail)
delete from t_quantitybalance where fdetailid not in (select fdetailid from t_itemdetail)
select * from t_profitandloss where fdetailid not in (select fdetailid from t_itemdetail)
delete from t_profitandloss where fdetailid not in (select fdetailid from t_itemdetail)
select * from t_itemdetail where fdetailid in (select fdetailid from t_itemdetailv where fitemid=-1)
|
|