重建索引:
DECLARE @name nvarchar(255)
–所有用户表游标
DECLARE authors_cursor CURSOR FOR
Select [name] from sysobjects where xtype=‘u’ order by id
OPEN authors_cursor
FETCH NEXT FROM authors_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
–修复数据表索引
DBCC DBREINDEX (@name, ‘’, 70)
– Get the next author.
FETCH NEXT FROM authors_cursor INTO @name
END
CLOSE authors_cursor
DEALLOCATE authors_cursor
go
#查看表索引碎片情况
use nfsscmuat
–创建变量 指定要查看的表
declare @table_id int
set @table_id=object_id(‘Instore’)
–执行
dbcc showcontig(@table_id)