SQL server 重建索引

-- 重建索引

declare @tn nvarchar(100)

DECLARE authors_cursor CURSOR FOR   select name from sysobjects where type = 'u'

OPEN authors_cursor

FETCH NEXT FROM authors_cursor INTO @tn

WHILE @@FETCH_STATUS = 0

BEGIN

print '-------------------'

print '重建表索引 : ' +@tn

dbcc dbreindex(@tn)

FETCH NEXT FROM authors_cursor INTO @tn

END

CLOSE authors_cursor

DEALLOCATE authors_cursor

-- ----------------------------------------

-- 修复数据库

-- DBCC CHECKDB('置疑的数据库名' , REPAIR_ALLOW_DATA_LOSS )

-- ----------------------------------------

Go 

posted on 2013-12-10 14:59  EasyBI  阅读(253)  评论(0)    收藏  举报

导航