SQL Server数据库所有表重建索引

USE My_Database;
DECLARE @name varchar(100)

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, '', 90)

   FETCH NEXT FROM authors_cursor  
   INTO @name 
END

deallocate authors_cursor

posted @ 2017-11-26 20:33  有梦就能实现  阅读(708)  评论(0编辑  收藏  举报