【问】库存查询按大类查询偶尔查询数据不全 | ||
【适用版本】专卖店9 | 【模块】基础业务 | 【点击数】14 |
【知识编号】Z2015122500024 | ||
【问题描述】库存查询按大类查询偶尔查询数据不全,需要多查询几次才会全。不是经常出 |
use isszmv9
go
—修复索引
use isszmv9–数据库名请根据修复的数据库进行更换。
go
declare @tablename varchar(100)
declare test_cur cursor for
select object_name(id) from sysobjects
where type =’U’
open test_cur
fetch test_cur into @tablename
while @@fetch_status=0
begin
DBCC DBREINDEX(@tablename)
fetch test_cur into @tablename
end
close test_cur
deallocate test_cur
go
–修复主键
use isszmv9
go
declare @tablename varchar(100)
declare test_cur cursor for
select object_name(id) from syscolumns
where status=128
open test_cur
fetch test_cur into @tablename
while @@fetch_status=0
begin
DBCC CHECKIDENT (@tablename, RESEED)
fetch test_cur into @tablename
end
close test_cur
deallocate test_cur
go