﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Tom Thomson  / Repairing with DBCC CHECKDB / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 07:31:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>[quote][b]kapil190588 (10/6/2012)[/b][hr]hi,Can anyone tell me How to check whether the database is in single user mode or multi user mode?[/quote][code="sql"]SELECT user_access, user_access_descFROM   sys.databasesWHERE  name = 'YourDatabase';[/code]</description><pubDate>Sat, 06 Oct 2012 10:46:00 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>hi,Can anyone tell me How to check whether the database is in single user mode or multi user mode?</description><pubDate>Sat, 06 Oct 2012 07:40:07 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Good question!</description><pubDate>Thu, 09 Aug 2012 08:33:12 GMT</pubDate><dc:creator>Neha05</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>[quote][b]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?[/quote] 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!</description><pubDate>Wed, 20 Jun 2012 14:45:55 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>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?</description><pubDate>Tue, 19 Jun 2012 02:14:34 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Easy one and no repairs would be done in this case.Thanks.</description><pubDate>Mon, 18 Jun 2012 11:29:15 GMT</pubDate><dc:creator>zymos</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Thanks Tom.</description><pubDate>Mon, 18 Jun 2012 11:18:27 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Good question.  I knew it wasn't valid any more but had forgotten that it wouldn't error.</description><pubDate>Fri, 15 Jun 2012 11:01:57 GMT</pubDate><dc:creator>cfradenburg</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Thanks for the question - cheers</description><pubDate>Fri, 15 Jun 2012 09:34:57 GMT</pubDate><dc:creator>OzYbOi d(-_-)b</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>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</description><pubDate>Fri, 15 Jun 2012 09:28:14 GMT</pubDate><dc:creator>Andre Ranieri</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>The typo has been corrected and points awarded back.My apologies for the typo.</description><pubDate>Fri, 15 Jun 2012 09:21:48 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>I got this right because my copy of Local Transact SQL Help says  as does BOL[quote]' database_name ' | database_id | 0Is 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_REBUILDSpecifies that DBCC CHECKDB repair the found errors. The specified database must be in single-user mode to use one of the following repair options.[/quote]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.</description><pubDate>Fri, 15 Jun 2012 08:30:36 GMT</pubDate><dc:creator>mtassin</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>in SQL 2012 running this you will get a syntex error near ","</description><pubDate>Fri, 15 Jun 2012 08:29:00 GMT</pubDate><dc:creator>David Smerchek</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>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.</description><pubDate>Fri, 15 Jun 2012 07:56:31 GMT</pubDate><dc:creator>Andre Ranieri</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>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.:-DHappy weekend everyone!!!"El" Jerry.</description><pubDate>Fri, 15 Jun 2012 07:43:30 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>The question specifically states 2008+ and on 2008 the syntax is invalid.  The first answer is the correct answer, not the answer you indicate.</description><pubDate>Fri, 15 Jun 2012 07:18:04 GMT</pubDate><dc:creator>Mark D Powell</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Since the syntax error due to the comma wasn't one of the choices, I assumed the comma was a typo and answered the question as if it wasn't there. Got it right.</description><pubDate>Fri, 15 Jun 2012 07:04:11 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>QOD &amp;lt;&amp;lt;FAIL&amp;gt;&amp;gt;</description><pubDate>Fri, 15 Jun 2012 06:58:37 GMT</pubDate><dc:creator>Steve Cullen</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Ugh, I didn't realize that had been depreciated.  Thanks for the question Tom!</description><pubDate>Fri, 15 Jun 2012 06:45:23 GMT</pubDate><dc:creator>sestell1</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Agree, got the same result as the post above above about syntax error. Is there any quality control on these questions?!?!</description><pubDate>Fri, 15 Jun 2012 06:29:48 GMT</pubDate><dc:creator>Mike Hays</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Apologies to everyone for the silly syntax error.I'll ask Steve to correct the question.</description><pubDate>Fri, 15 Jun 2012 06:03:07 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>I get: " Incorrect syntax near ','You have to specify a db name.Edit:Heheheh - I see several others have latched onto the incorrect correct answer conundrum too. Mgilchrist = bad :-D</description><pubDate>Fri, 15 Jun 2012 04:35:40 GMT</pubDate><dc:creator>Michael G</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Interesting question and have learnt something today, however I have to agree that the answer is actually wrong, as if you want to add any options to the DBCC command you have to specify the database name - and that in (). So i would say that the answer should be the Error due to database name being required. Even adding the database name and once you get the command to actually run, you still get the error that "Repair statement not processed. Database needs to be in single user mode."If you have that, then you will get the actual answer that has been specified!I definitely feel we shoudl get a point for the first error at any rate!</description><pubDate>Fri, 15 Jun 2012 02:49:49 GMT</pubDate><dc:creator>Michael Riemer</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>When I execute the command given in the question, I get the following error:[quote]Msg 102, Level 15, State 1, Line 1Incorrect syntax near ','.[/quote]That's because you need to specify the database name in order to use the Repair_Fast option. So I choose answer 1, which was - to my surprise - incorrect.edit: I see vk-kirov has already said the same thing. Whoopsie.</description><pubDate>Fri, 15 Jun 2012 02:42:04 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Interesting question, thanks Tom.Haven't used this option since SQL2000.I presume this will eventually become deprecated.</description><pubDate>Fri, 15 Jun 2012 02:29:38 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>There is also a forum discussion where Paul Randal has some comments. Check this [url=http://www.sqlservercentral.com/Forums/Topic405557-266-1.aspx#bm409239]LINK[/url].</description><pubDate>Fri, 15 Jun 2012 02:20:56 GMT</pubDate><dc:creator>mohammed moinudheen</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Got me!  Good one, thanks!Bex</description><pubDate>Fri, 15 Jun 2012 01:20:59 GMT</pubDate><dc:creator>Bex</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>This is a good idea for QOD, unfortunately the QOD itself was ruined by a syntax error. The REPAIR_FAST argument cannot be used without a database name or ID.[url]http://msdn.microsoft.com/en-us/library/ms176064.aspx[/url][quote]DBCC CHECKDB (Transact-SQL)Syntax[hr][code]DBCC CHECKDB [    [ ( database_name | database_id | 0        [ , NOINDEX         | , { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD } ]    ) ]    [ WITH         {            [ ALL_ERRORMSGS ]            ...        }    ]][/code][/quote]When you try to run the command "DBCC CHECKDB , REPAIR_FAST", you get the following error: "[color="red"]Msg 102, Level 15, State 1, Line 1. Incorrect syntax near ','.[/color]"The correct syntax is something like "DBCC CHECKDB (AdventureWorks, REPAIR_FAST)" or "DBCC CHECKDB (5,  REPAIR_FAST)".And the correct answer to the QOD is "returns an error message - you have to specify a database".</description><pubDate>Fri, 15 Jun 2012 01:01:32 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Ah, I see, looked at the wrong SQL-Server version.</description><pubDate>Fri, 15 Jun 2012 00:19:53 GMT</pubDate><dc:creator>ma-516002</dc:creator></item><item><title>RE: Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Is the "no repair" answer correct?http://msdn.microsoft.com/en-us/library/aa258278%28SQL.80%29.aspxsays:REPAIR_FAST 	Performs minor, nontime-consuming repair actions such as repairing extra keys in nonclustered indexes. These repairs can be done quickly and without risk of data loss.</description><pubDate>Fri, 15 Jun 2012 00:18:31 GMT</pubDate><dc:creator>ma-516002</dc:creator></item><item><title>Repairing with DBCC CHECKDB</title><link>http://www.sqlservercentral.com/Forums/Topic1316289-2681-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/Administration/90770/"&gt;Repairing with DBCC CHECKDB&lt;/A&gt;[/B]</description><pubDate>Thu, 14 Jun 2012 22:22:56 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item></channel></rss>