Syntax for DBCC CHECKTABLE on all indexes?

Posted by GuinnessFan on Server Fault See other posts from Server Fault or by GuinnessFan
Published on 2009-09-17T18:25:01Z Indexed on 2010/04/10 11:53 UTC
Read the original article Hit count: 244

Filed under:

Just want to check the syntax to make sure this is for one table and all indexes (default?). --must be single user

ALTER DATABASE database_name SET SINGLE_USER;

DBCC CHECKTABLE
( "table_name"
    , REPAIR_ALLOW_DATA_LOSS 
)
WITH ALL_ERRORMSGS;

-- TURN BACK MULTI USER
ALTER DATABASE database_name SET MULTI_USER;

Also, should I be in the database containing the table to repair or should I be in master?

© Server Fault or respective owner

Related posts about sql-server-2005