金蝶K3供应链反初始化SQL

发布时间 : 星期五 文章金蝶K3供应链反初始化SQL更新完毕开始阅读

金蝶K3软件物流反初始化的SQL语句 提醒:执行语句前一定要先备份账套! 以下为SQL语句具体内容:

If exists (select * from sysobjects where name='RestartSystem' and type='P')---检查存储过程是否存在

Drop procedure RestartSystem ----存在则删除之 Go

Create Procedure RestartSystem ---定义存储过程 AS

Declare @StartPeriodint, @startyearint,

@CurStartDatevarchar(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 AndFCancellation=0)

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

第 1 页 共 2 页

----处理系统参数

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 FCategory='IC' Return Go

------启动帐套

Exec RestartSystem Go

Set FValue='1' Where 第 2 页 共 2 页

FKey='ICClosed' and

联系合同范文客服:xxxxx#qq.com(#替换为@)