重建所有索引



--重建所有索引
CREATE PROC [dbo].[RDBULD_INDEX]
AS
DECLARE @name varchar(50);
DECLARE tblCsr CURSOR LOCAL FOR SELECT name FROM sys.tables 
WHERE NAME NOT IN ('tRackInf', 'tRackHis', 'tStation');
OPEN tblCsr;
WHILE(1=1)
BEGIN
FETCH NEXT FROM tblCsr INTO @name;
IF(@@FETCH_STATUS<>0)
BREAK;
PRINT @name;
DBCC DBREINDEX(@name, '', 90);
END
CLOSE tblCsr;
DEALLOCATE tblCsr;
DBCC DBREINDEX(tRackInf, '', 70);
DBCC DBREINDEX(tRackHis, '', 70);
DBCC DBREINDEX(tStation, '', 70);

你可能感兴趣的:(索引,select,实例)