what does DBCC DBREINDEX('?', ' ', 80) do?

sql, sql-server, sql-server-2008

Solution

Not quite - when you use `sp_MSforeachtable`, the question mark is a placeholder for the the table name (as it loops through each table in turn).

In reply to your second question from the comments, yes - according to the documentation on DBCC DBREINDEX about the second argument:

If index_name is specified, table_name must be specified. If index_name is not specified or is " ", all indexes for the table are rebuilt.

Problem

What exactly does the following statement do? Does it reindex all tables named '?' with a fill factor of 80% ? ``` EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)" ``` It did improve query time from 23 seconds to almost instantly but I'd like to understand why.

Original source