Rebuilding Stats: Twice or Not At All
Are you rebuilding statistics twice on your tables? Longtime expert, Andy Warren, shows why you might be asking more work of your SQL Server than is required.
2008-07-29
9,130 reads
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