DBCC DBREINDEX is a has been announced to be deprecated for more than 10 years ago, meaning it may disappear in future versions of SQL Server.
DBCC DBREINDEX is a database console command (DBCC) in Microsoft SQL Server that can be used to rebuild the indexes of a database.
DBCC DBReIndex has been deprecated meaning that Microsoft has announced that DBCC DBReIndex will be going away in future versions of SQL Server
Rebuilding the indexes can be useful for improving the performance of queries that use the indexes, or for correcting index fragmentation caused by frequent updates to the data.
To use DBCC DBREINDEX, you must specify the name of the database you want to rebuild the indexes for. You can also specify the TABLE option and the name of a specific table to rebuild the indexes for only that table.
Here is an example of how to use DBCC DBREINDEX to rebuild the indexes for the entire “MyDatabase” database:
-- Rebuild the indexes for the entire "MyDatabase" database
DBCC DBREINDEX ('MyDatabase');
Here is an example of how to use DBCC DBREINDEX to rebuild the indexes for a specific table in the “MyDatabase” database:
-- Rebuild the indexes for the "Customers" table in the "MyDatabase" database
DBCC DBREINDEX ('MyDatabase', 'Customers')
The output of DBCC DBREINDEX will be a message indicating whether the operation was successful or not. If the operation was successful, the indexes for the specified database or table will be rebuilt.
Please note that DBCC DBREINDEX can be a resource-intensive operation, as it requires rebuilding all of the indexes in the database or table.
There is more functionality in the ALTER INDEX than in DBCC DBReIndex.
The following example shows how to use ALTER INDEX insted of DBCC DbReIndex.
ALTER INDEX [ClusteredCPU]
ON [dbo].[CPU]
REORGANIZE WITH ( LOB_COMPACTION = ON );
Need help with this or an of the other DBCC commands? The team at Stedman Solutions, LLC specializes in repairing corrupt databases and heping when things go wrong.
More from Stedman Solutions:
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!