SQL Flow Field Guide

DBCC INDEXDEFRAG

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

DBCC INDEXDEFRAG: administrative check or maintenance

What changes

Input
database, table, index, cache or server state named in the command
Output or change
messages or result sets; maintenance forms change storage, caches or metadata

Syntax at a glance

DBCC INDEXDEFRAG ( { database_name | database_id | 0 } , { table_name | table_id | view_name | view_id } [ , { index_name | index_id } [ , { partition_number | 0 } ] ] ) [ WITH NO_INFOMSGS ]

Work example

An old maintenance job still calls the deprecated DBCC INDEXDEFRAG command.

Plan a move to ALTER INDEX REORGANIZE and compare the target index and online workload needs.

Check your work The replacement handles the same index without relying on deprecated syntax.

Open Microsoft Learn for full syntax, permissions, and details for your version.