Technical Article

Simple script to ReIndex complete database

,

DECLARE @TableName varchar(255)

DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_name not like 'sys%' and table_name  <>'dtproperties'
OPEN TableCursor

FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN 
PRINT 'Reindexing ' + @TableName
DBCC DBREINDEX(@TableName,' ',90)-- change fill factor here as per your requirement

FETCH NEXT FROM TableCursor INTO @TableName
END

CLOSE TableCursor

DEALLOCATE TableCursor

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating