Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

586


Part V: Enterprise Data Management


DBCC Commands


Microsoft SQL Server Database Console Commands (DBCC) are used for checking database
integrity; performing maintenance operations on databases, tables, indexes, and fi legroups;
and collecting and displaying information during troubleshooting issues.

The fi rst DBCC command to become familiar with is the DBCC HELP command, which
returns the syntax with all the options for any DBCC command. The following command
returns the syntax for DBCC CHECKDB.

DBCC HELP ('CHECKDB');

Result:

dbcc CHECKDB
(
{ 'database_name' | database_id | 0 }
[ , NOINDEX
| { REPAIR_ALLOW_DATA_LOSS
| REPAIR_FAST
| REPAIR_REBUILD
} ]
)
[ WITH
{
[ ALL_ERRORMSGS ]
[ , [ NO_INFOMSGS ] ]
[ , [ TABLOCK ] ]
[ , [ ESTIMATEONLY ] ]
[ , [ PHYSICAL_ONLY ] ]
[ , [ DATA_PURITY ] ]
[ , [ EXTENDED_LOGICAL_CHECKS ] ]
}
]
DBCC execution completed. If DBCC printed error messages,
contact your system administrator.

The following command returns all DBCC commands for which help is available.

DBCC HELP ('?');

c22.indd 586c22.indd 586 7/31/2012 9:24:29 AM7/31/2012 9:24:29 AM


http://www.it-ebooks.info
Free download pdf