Sql-server – Best way to rebuild all indexes on all tables in SQL Server 2005

sql serversql-server-2005

A google search turns up some scripts that run a query against system tables and iterate over the the results rebuilding (or alternatively, reorganizing) each of your database table indexes in turn. This seems reasonable but the he reason I ask the question here is that taking SQL scripts from an unknown source that query system tables makes me nervous, e.g. maybe it will miss some kinds of index or try and rebuild special system indexes that should be left alone. As it happens the first couple I tried didn't work because they didn't handle tables in different schemas.

So, what is the consensus on the best and simplest way to rebuild all indexes across all tables for an SQL Server 2005 database?

Thankyou.

Best Answer

If you don't want to risk a third party script, the native maintenance plans include the option of rebuilding all of the indexes for each database.

Related Topic