|
DBCC CHECKTABLE - Check the integrity of a table or indexed view.
Syntax DBCC CHECKTABLE
('table' | 'view'
[ , { NOINDEX | index_id }
|, { REPAIR_ALLOW_DATA_LOSS | REPAIR_REBUILD }
]
)
[WITH
[ALL_ERRORMSGS
NO_INFOMSGS ]
[ , TABLOCK ] [ , ESTIMATEONLY ] [ , PHYSICAL_ONLY ]
] 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
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
DBCC CHECKCONSTRAINTS - Check integrity of table constraints.