DBCC CHECKTABLE - Check the integrity of a table or indexed view.

Syntax
      DBCC CHECKTABLE 
      ('table' | 'view'
         [ , { NOINDEX | index_id }
         |, { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD }
         ] 
      )
      [WITH 
       { ALL_ERRORMSGS ]
         [ , EXTENDED_LOGICAL_CHECKS ]
         [ , NO_INFOMSGS ]
         [ , TABLOCK ]
         [ , ESTIMATEONLY ]
         [ , { PHYSICAL_ONLY | DATA_PURITY } ]
         [ , MAXDOP = number_of_processors ]
       }
      ]

Key:
   NOINDEX        - Skip intensive checks of nonclustered indexes.

   REPAIR_ALLOW_DATA_LOSS - Try to repair all reported errors*.

   REPAIR_REBUILD - Perform all repairs that can be performed without risk of data loss.

   REPAIR_FAST    - Deprecated option.

   ALL_ERRORMSGS  - Return all reported errors per object, default = first 200 errors.

   TABLOCK        - Obtain locks instead of using an internal database snapshot.

   ESTIMATEONLY   - Display the estimated amount of tempdb space that would be required.

   PHYSICAL_ONLY  - Limits the checking to the integrity of the physical structure.

   EXTENDED_LOGICAL_CHECKS - If the compatibility level is 100 (SQL Server 2008) or higher,
                    perform logical consistency checks on indexed views, XML indexes,
                    and spatial indexes.

   DATA_PURITY    - Check the table for column values that are not valid or out-of-range.

   MAXDOP         - Override the max degree of parallelism configuration option of
                    sp_configure for the statement.

Use the DATA_PURITY option for databases upgraded from versions of SQL Server earlier than 2005.

* To repair errors restore from a backup, use the REPAIR options only as a last resort.

Examples

-- Check the integrity of MyTable in 'MyDatabase'
USE MyDatabase;
GO
DBCC CHECKTABLE ('MySchema.MyTable')
GO

“We're going to rebuild and rebuild stronger” ~ Mayor Rudolph Giuliani

Related commands

DBCC CHECKCONSTRAINTS - Check integrity of table constraints.


 
Copyright © 1999-2026 SS64.com
Some rights reserved