阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 1178|回复: 1

[原创] 期初账面及实际不对请运行本程序(慎用)5000工业版3.4以后版本都可以用

[复制链接]
  • TA的每日心情
    擦汗
    2024-3-11 10:27
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    发表于 2009-3-5 10:16:11 | 显示全部楼层 |阅读模式
    执行前备份数据
    (请在查询管理器中运行,然后反结账到期初的月再结账到到当前月,这样库存就对了
    程序中的这个是开账年月要改一下根据自己的posyear=2009 and posmonth=1 )


    declare @goodsid int, @storeid int,@sumqty int
    declare cur_calc cursor local forward_only static read_only for
    select goodsid,storeid,sum(quantity) as sumqty from aa_billflow where billid<0 group by goodsid,storeid
    open cur_calc
    fetch next from cur_calc into @goodsid,@storeid,@sumqty
          while @@fetch_status = 0
          begin   
            update aa_storebalance
            set bqty=isnull(@sumqty,0), brqty=isnull(@sumqty,0)
            where [email=storeid=@storeid]storeid=@storeid[/email] and [email=goodsid=@goodsid]goodsid=@goodsid[/email] and posyear=2009 and posmonth=1 --and bqty<>brqty     
                
          fetch next from cur_calc into @goodsid,@storeid,@sumqty
          end
    close cur_calc
    deallocate cur_calc

            update aa_storebalance
            set bqty=0, brqty=0
            where not exists (select * from aa_billflow
                                where aa_storebalance.storeid=aa_billflow.storeid and aa_storebalance.goodsid=aa_billflow.goodsid and aa_billflow.billid<0)
            and aa_storebalance.bqty<>0

    [ 本帖最后由 cyjxj 于 2009-3-5 12:16 编辑 ]
    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2017-1-3 16:17
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2009-3-5 11:56:57 | 显示全部楼层
    厉害,还没用到速达的。
    另外,请教一个:
    有什么书箱可以快速精通SQL的?
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表