Monday, July 18, 2005

DBCC CheckTable Syntax and Examples

Syntax
DBCC CHECKTABLE
( ’table_name’ | ’view_name’
[ , NOINDEX
| index_id
| { REPAIR_ALLOW_DATA_LOSS
| REPAIR_FAST
| REPAIR_REBUILD }
]
) [ WITH { [ ALL_ERRORMSGS | NO_INFOMSGS ]
[ , [ TABLOCK ] ]
[ , [ ESTIMATEONLY ] ]
[ , [ PHYSICAL_ONLY ] ]
}
]


Examples
A. Check a specific table
This example checks the data page integrity of the authors table.

DBCC CHECKTABLE (’authors’) GO
B. Check the table without checking nonclustered indexes
This example checks the data page integrity of the authors table without checking nonclustered indexes.

DBCC CHECKTABLE (’authors’) WITH PHYSICAL_ONLY GO
C. Check a specific index
This example checks a specific index, obtained by accessing sysindexes.

USE pubs DECLARE @indid int SELECT @indid = indid FROM sysindexes WHERE id = OBJECT_ID(’authors’) AND name = ’aunmind’ DBCC CHECKTABLE (’authors’, @indid) GO

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home