管家婆辉煌7.2,,非常老的版本。
VFP的DBF数据库。
经过分析,由于年结存删除了单据明细以及历史数据导致的。在电脑 里面找以前的备份,,找到了一个,恢复后提示 这段时间无过帐单据。
经过分析发现是备份的不完整,缺失了单据索引。。
我们需要语句重建索引。
--修复表缺少单据汇总索引
ALTER TABLE [365] ADD ID INT IDENTITY
GO
ALTER TABLE dly ADD ID INT IDENTITY
GO
ALTER TABLE dlyndx ADD ID INT IDENTITY
GO
--设置单据日期索引
declare m_cursor cursor scroll for
select id ,dly_count from [365] where id > (select id from [365] where date = '2022-09-07')
open m_cursor
declare @date varchar(50), @id int ,@dly_count int ,@kstime datetime ,@day int ,@yeas int ,@month int
set @kstime = '2022-09-08'
set @yeas = 2022
set @month = 9
set @day = 8
fetch next from m_cursor into @id ,@dly_count
while @@FETCH_STATUS=0
begin
if (@day > 31)
begin
set @day = 1
set @month = @month + 1
end
if (@month > 12)
begin
set @month = 1
set @yeas = @yeas + 1
end
update [365] set date = right(('00'+convert(varchar(100),@yeas)),4) +
'-' + right(('00'+convert(varchar(100),@month)),2) +
'-' + right(('00'+convert(varchar(100),@day)),2)
where id = @id
set @day =@day + 1 ;
fetch next from m_cursor into @id ,@dly_count
end
close m_cursor
deallocate m_cursor