Repairing with DBCC CHECKDB

  • The question specifically states 2008+ and on 2008 the syntax is invalid. The first answer is the correct answer, not the answer you indicate.

  • Got me on this one because I read an old version of BOL. I knew there was a syntax error but I focused only on the words and not the punctuation.

    I should pay attention to versions in later QOTDs.:-D

    Happy weekend everyone!!!

    "El" Jerry.

    "El" Jerry.

    "A watt of Ottawa" - Gerardo Galvan

    To better understand your help request, please follow these best practices.[/url]

  • I got this one wrong (or right) because my answer assumes that DBCC CheckDB requires a database name, and in parentheses. At any rate, I didn't get the point but it was nice to brush up on some SQL history.

    Thanks.

  • in SQL 2012 running this you will get a syntex error near ","

  • I got this right because my copy of Local Transact SQL Help says as does BOL

    ' database_name ' | database_id | 0

    Is the name or ID of the database for which to run integrity checks. If not specified, or if 0 is specified, the current database is used. Database names must comply with the rules for identifiers.

    REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD

    Specifies that DBCC CHECKDB repair the found errors. The specified database must be in single-user mode to use one of the following repair options.

    I read it such that if you don't specify a database it will default to the current one. I guess not with the REPAIR commands?

    Originally I thought it was an error... but reading that it seems that it should be right... it's not... but I think it should be.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • The typo has been corrected and points awarded back.

    My apologies for the typo.

  • As a point of intellectual curiosity, when I run this against my sandbox database (SQL 2008 R2) I get an error that the database needs to be in single user mode.

    Thanks again for everything. I start every morning with the SSC QoTD, and it has taught me an awful lot.

    Andre Ranieri

  • Thanks for the question - cheers

  • Good question. I knew it wasn't valid any more but had forgotten that it wouldn't error.

  • Thanks Tom.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Easy one and no repairs would be done in this case.

    Thanks.

  • Am I allowed to complain that I got an error because I have no such database as Adventureworks? 😉

    I knew that repair_fast no longer worked, but guessed wrong that it would fail with an error rather than just being ignored. I hate it when MS do this - backward compatibility is all very well but in some cases can lead you to think that an action has completed successfully rather than doing nothing! Am I the only one who'd rather start getting error messages so I knew I had to fix my code?

  • I knew that repair_fast no longer worked, but guessed wrong that it would fail with an error rather than just being ignored. I hate it when MS do this - backward compatibility is all very well but in some cases can lead you to think that an action has completed successfully rather than doing nothing! Am I the only one who'd rather start getting error messages so I knew I had to fix my code?

    You're certainly not the only one. A warning message might be OK instead of an error, but quietly doing nothing is irritating.

    edit:spelling!

    Tom

  • Good question!

  • hi,

    Can anyone tell me How to check whether the database is in single user mode or multi user mode?

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

Viewing 15 posts - 16 through 30 (of 30 total)

You must be logged in to reply to this topic. Login to reply