服务器数据库密码老是被修改,你好,数据库服务器和应用服务器是分离部署的,之前一直好的,最近数据库服务器的数据库密码老是变掉,导致访问的时候出现18456数据库报错,需要我手工改一下数据库密码,然后重新...

可以通过库存--业务处理--库存帐与货位帐对账功能查询出所有有问题存货,这些有问题的存货可通过下面的脚本定位到错误单据。脚本如下:

select * from (

select rd.cvouchtype,rd.cBusType,rd.cWhCode,rd.dDate,rd.cCode,brdflag,chandler,rds.AutoID,rds.cInvCode,rds.iQuantity as 出入库数量,cp.iQuantity as 货位记录数量,rds.cBatch,rds.cFree1,rds.cfree2,rds.cFree3,rds.cPosition from rdrecord rd inner join RdRecords rds on rd.ID=rds.ID

inner join (select cwhcode,cinvcode,RdsID,cBatch,cfree1,cfree2,cFree3,sum(iquantity) as iquantity from invposition group by cwhcode,cinvcode,RdsID,cBatch,cfree1,cfree2,cFree3) cp on rds.AutoID=cp.RdsID

where rds.iQuantity<>cp.iQuantity

union

select cvouchtype,cbustype,a.cWhCode,dDate,cCode,bRdFlag,chandler,AutoID,cInvCode,iQuantity as 出入库数量,0 as 货位记录数量,cBatch,cFree1,cFree2,cfree3,cPosition from rdrecord a inner join rdrecords b on a.id=b.id left join warehouse c on a.cWhCode=c.cWhCode where bwhpos=1 and (cHandler is null or cHandler='' or (cHandler is not null and cHandler<>'' and biafirst=0)) and AutoID not in (select rdsid from InvPosition where cSource is null)

union

select '无出入库但有货位记录,可直接在InvPosition找到此数据删除即可' as cvouchtype,'' as cbustype,cwhcode,ddate,'' as ccode,brdflag,chandler,rdsid,cinvcode,iquantity as 出入库数量,0 as 货位记录数量,cBatch,cFree1,cFree2,cfree3,cPosCode from InvPosition where cSource is null and rdsid not in (select autoid from rdrecord a inner join rdrecords b on a.id=b.id left join warehouse c on a.cWhCode=c.cWhCode where bwhpos=1 )

) a order by cinvcode,cwhcode,cbatch,cfree1,cfree2,cfree3

--原理:1、rdrecord与invposition表管理查询出rds中记录的数据与invposition表中记录的数据不等的存货;

--2、查询出(货位仓中单据未审核、或者货位仓中单据已审核且不是存货期初)、且未在货位表中找到记录的单据;

--3、查询出无出入库单据但有货位记录的错误数据(注意:已排除货位调拨的情况);

针对第三种可以通过脚本解决,解决方案:直接在数据库中删除第三种情况的数据:

--首先备份这部分数据

select * into tempdb..InvPosition_152556_2013bak from InvPosition where cSource is null and rdsid not in (select autoid from rdrecord a inner join rdrecords b on a.id=b.id left join warehouse c on a.cWhCode=c.cWhCode where bwhpos=1 )

--删除这部分数据

delete from InvPosition where cSource is null and rdsid not in (select autoid from rdrecord a inner join rdrecords b on a.id=b.id left join warehouse c on a.cWhCode=c.cWhCode where bwhpos=1 )

后期关于货位表与库存对账的问题,均可通过上述方法解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值