Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
2  
Why are you running repair? What errors did CheckDB (without the repair clause) return? Are there no backups that you can restore from instead of repairing? Do you know how much data repair is going to delete? –  GilaMonster Sep 19 '09 at 14:11
    
Fortunately, this was a rarely used table in a db for a 3rd party app. Our test environment showed no data loss. This was more of an exercise. All precautions mentioned by GilaMonster should be taken. –  user11064 Nov 18 '09 at 16:39

1 Answer 1

The syntax is correct, and it will check all indexes unless a specific one is given.

You should be in the database where the table resides.

More info here: http://msdn.microsoft.com/en-us/library/ms174338.aspx.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.