DBCC INDEXDEFRAG 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 INDEXDEFRAG is a database console command (DBCC) in Microsoft SQL Server that can be used to defragment the indexes of a database. Defragmenting 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 INDEXDEFRAG, you must specify the name of the database and the name of the table you want to defragment the indexes for. You can also specify the INDEX option and the name of a specific index to defragment only that index.
Here is an example of how to use DBCC INDEXDEFRAG to defragment the indexes for the “Customers” table in the “MyDatabase” database:
-- Defragment the indexes for the "Customers"
-- table in the "MyDatabase" database
DBCC INDEXDEFRAG ('MyDatabase', 'Customers')
Here is an example of how to use DBCC INDEXDEFRAG to defragment a specific index in the “Customers” table in the “MyDatabase” database:
-- Defragment the "IX_Customers_LastName" index in
-- the "Customers" table in the "MyDatabase" database
DBCC INDEXDEFRAG ('MyDatabase', 'Customers', 'IX_Customers_LastName')
The output of DBCC INDEXDEFRAG will be a message indicating whether the operation was successful or not. If the operation was successful, the indexes for the specified table or index will be defragmented.
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!