6

Is it possible to run: DBCC CHECKDB on a specific table in SQL Server 2005 database?

I have the following syntax:

DBCC CHECKDB 
[
    [ ( database_name | database_id | 0
        [ , NOINDEX 
        | , { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD } ]
    ) ]
    [ WITH 
        {
            [ ALL_ERRORMSGS ]
            [ , EXTENDED_LOGICAL_CHECKS ] 
            [ , NO_INFOMSGS ]
            [ , TABLOCK ]
            [ , ESTIMATEONLY ]
            [ , { PHYSICAL_ONLY | DATA_PURITY } ]
        }
    ]
]

But keep getting incorrect syntax. I just want to run it to see what errors it throws up? Can you help me with writing the syntax? I want to remove all repair options.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
PriceCheaperton
  • 5,071
  • 17
  • 52
  • 94

2 Answers2

15

DBCC CHECKDB as it names apply is for checking databases.

There is a DBCC CHECKTABLE command for checking specific tables. Usage is:

DBCC CHECKTABLE ('YourTable');
Nenad Zivkovic
  • 18,221
  • 6
  • 42
  • 55
  • I have just ran, `DBCC CHECKDB(AdventureWorks2008R2)` that wont repair anything will it???????????? !! – PriceCheaperton Jul 18 '13 at 11:37
  • 5
    DBCC CHECKTABLE ('YourTable',REPAIR_REBUILD) – Nenad Zivkovic Jul 18 '13 at 11:50
  • Hi, I just stumble to this post after searching for answers with my problem on the table of my db with logical consistency. my question does dbcc checktable(yourtable, REPAIR_REBUILD) can repair this kind of error? – Androidz Feb 06 '15 at 02:12
0

Late to the party, but, oh, well... See MS DBCC CHECKTABLE

Syntax:
DBCC CHECKTABLE ( table_name | view_name [ , { NOINDEX | index_id } |, { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD } ] ) [ WITH { [ ALL_ERRORMSGS ] [ , EXTENDED_LOGICAL_CHECKS ] [ , NO_INFOMSGS ] [ , TABLOCK ] [ , ESTIMATEONLY ] [ , { PHYSICAL_ONLY | DATA_PURITY } ] [ , MAXDOP = number_of_processors ] } ]

Be careful using any of the REPAIR options. Note that the ESTIMATEONLY Argument is just that and ZERO impact, and the PHYSICAL_ONLY option may have a much shorter run-time on large tables.

T-Bone
  • 21
  • 4