Update Statistics and Rebuild Indexes

I have a failing job to rebuild indexes and update stats and no time to troubleshoot before they need to run

So if anyone ever needs to do this manually (please note that the 80 will set fill factor to 80)

USE @databaseName
GO
EXEC sp_MSforeachtable @command1=”print ‘?’ DBCC DBREINDEX (‘?’, ‘ ‘, 80)”
GO
EXEC sp_updatestats
GO

Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *