用友畅捷通T+收发存汇总表和存货总账结存不一致
账套备份
执行以下语句
UPDATE r2 SET r2.amount = xx.outAmount , r2.price = round (xx.outAmount/r2.quantity,2),
r2.basePrice = ROUND(xx.outAmount/r2.baseQuantity,2)
FROM dbo.ST_RDRecord r1
JOIN dbo.ST_RDRecord_b r2 ON r1.id = r2.idRDRecordDTO
JOIN dbo.AA_Inventory i ON r2.idinventory = i.id
JOIN (
SELECT s.idvouchertype, s.voucherDetailID, s.voucherID, SUM(s.outAmount) AS outAmount
FROM dbo.ST_SubsidiaryBook s
GROUP BY s.idvouchertype, s.voucherDetailID, s.voucherID
) xx ON r1.id = xx.voucherID AND r1.idvouchertype = xx.idvouchertype AND r2.id = xx.voucherDetailID
WHERE r2.amount <> xx.outAmount AND r1.rdDirectionFlag = 0