To run these queries from the command line, refer to the Article How to run queries from a command prompt.
Additionally, while the 'scan' (no parameters passed) can be run while in the standard multi-user mode, performing repairs requires changing the database to single-user mode.
DBCC CHECKTABLE ('table_name') - In order to check an entire database in Microsoft SQL Server the following command will need to be used via command line or query manager.
DBCC CHECKDB ('database_name') - Both commands have the following repair options:
REPAIR_ALLOW_DATA_LOSS - Performs all repairs done by REPAIR_REBUILD and includes allocation and deallocation of rows and pages for correcting allocation errors, structural row or page errors, and deletion of corrupted text objects.
These repairs can result in some data loss. The repair may be done under a user transaction to allow the user to roll back the changes made.
If repairs are rolled back, the database will still contain errors and should be restored from a backup.
If a repair for an error has been skipped due to the provided repair level, any repairs that depend on the repair are also skipped.
After repairs are completed, back up the database.
REPAIR_FAST - Performs minor, non-time-consuming repair actions such as repairing extra keys in non-clustered indexes. These repairs can be done quickly and without risk of data loss.
For a complete list of syntax and examples for checking tables and databases refer to the following Microsoft Knowledge Base articles:
For a complete list of syntax and examples for checking tables and databases refer to the following Microsoft Knowledge Base articles:
DBCC CHECKTABLE - http://msdn2.microsoft.com/en-us/library/Aa258646
DBCC CHECKDB - http://msdn2.microsoft.com/en-us/library/Aa258278
Changing database to/from single-user mode - http://msdn2.microsoft.com/en-us/library/ms345598.aspx