• [求助] 金蝶K3软件物流反初始化的SQL语句

    作者:
    积分:2313
    等级:初中
    经验值:318
    威望:2050
    发帖数:102
    回帖数:7
    精华数:102
    注册时间:2008-11-24
    在线时间:

    金蝶K3软件物流反初始化的SQL语句

    环境参数

    WIN 2003 SQL2000

    内 容

    执行以下SQL语句:
           
             If exists (select * from sysobjects where name='RestartSystem' and type='')---检查存储过程是否存在
    Drop procedure RestartSystem ----存在则删除之
    Go
    Create Procedure RestartSystem ---定义存储过程
    AS
    Declare @StartPeriod int,
    @startyear int,
    @CurStartDate varchar(20)


    ----处理余额和即时库存数据
    Delete From ICBal
    Delete From ICInvBal
    Delete From ICInventory
    Delete From ICInvInitial Where FPeriod>0

    ----取帐套启用时间
    select @startyear=convert(int,FValue) from t_SystemProfile where FCategory='ic' and FKey='startyear'
    select @startperiod=convert(int,FValue) from t_SystemProfile where FCategory='ic' and FKey='startperiod'
    select @CurStartDate=convert(varchar(4),@startyear)+ '-' + convert(varchar(2),@startperiod)+'-'+'01'
    ---select @CurStartDate=convert(varchar,convert(datetime, @CurStartDate),110)
    ---select @CurStartDate=substring( @CurStartDate,7,4)+'-'+substring( @CurStartDate,1,2)+'-'+substring( @CurStartDate,4,2)


    ----处理起用前的数据
    delete from t_MakevouchTemp where FTranType=4000 and fgroupid=0 and fvchinterid=-1 and fprevchinterid=0
    and fscbillinterid in (select finterid from icstockbill where fdate <@CurStartDate AND FTranType=1 And FCancellation=0)

    delete from ICSaleVoucher WHERE finterid in(select finterid from icstockbill where FDate<@CurStartDate AND FTranType=21 AND FSaleStyle=102 And FCancellation=0)

    Update ICstockBill set FVchInterID=Null Where FDate<@CurStartDate AND FTranType=1 and FCancellation=0


    ----处理系统参数
    Update t_SystemProfile Set FValue='0' Where FKey='ICClosed' and FCategory='IC'
    Update t_SystemProfile Set FValue=convert(varchar(2),@startperiod) Where FKey='CurrentPeriod' and FCategory='IC'
    Update t_SystemProFile Set FValue='0' Where FKey='InvDataPeriod' And FCategory='IC'

    ----转换初始余额数据时间
    Update ICInvInitial Set FPeriod=convert(int,@StartPeriod) Where FPeriod=0

    --Exec StockIniDataOn
    --Update t_SystemProfile Set FValue='1' Where FKey='ICClosed' and FCategory='IC'
    Return
    Go
    ------启动帐套
    Exec RestartSystem
    Go

    10    
    2009-09-12 0 0 该问答已过期 顶端
  • 关于我们   |   联系我们   |   服务条款   |   问题反馈