SQL Server Interview Question #194
What is DBCC CHECKDB?
Security, Backup, Recovery, Administration & Real-World Scenarios Senior Advanced
Detailed Explanation
DBCC CHECKDB checks the logical and physical integrity of database objects and allocation structures. It is a core SQL Server database-integrity tool.
Production environments should run CHECKDB on a schedule appropriate to database size, criticality, and operational constraints. If corruption is found, the preferred response is normally to determine the cause and restore from known-good backups rather than immediately using repair options that may cause data loss.
Code Example
DBCC CHECKDB ('SalesDb') WITH NO_INFOMSGS;