Thursday, November 13, 2008

Rebuild All Indexes on All Tables

Here's a small script to rebuild all the indexes on all the tables in a given database:

EXEC sp_MsForEachTable 'USE [YourDatabase]  PRINT ''?''  DBCC DBREINDEX (''?'', '' '', 70)'

Be sure to read Books OnLine about "DBCC DBREINDEX" - it's probably not something you want to do during peak hours.

0 comments:

Post a Comment