Search

Friday, February 5, 2010

Reindex an entire database

The following query is to reindex an entire database.

EXEC [sp_MSforeachtable] @command1="DBCC DBREINDEX('?')"

If you want to receive progress messages while it is running, try this version

EXEC [sp_MSforeachtable] @command1="RAISERROR('DBCC DBREINDEX(''?'') ...',10,1)
WITH NOWAIT DBCC DBREINDEX('?')"

Click here for reference.

No comments:

Post a Comment