dbcc checktable repair_rebuild

Syntax:
[sql]
DBCC CHECKTABLE(‘TableName’,REPAIR_REBUILD)
[/sql]

This command checks the integrity of the table with respect to pages and structures and repairs it with no possible loss.

Example:
[sql]
ALTER DATABASE AdventureWorksDW2008R2 SET SINGLE_USER
DBCC CHECKTABLE(‘DatabaseLog’,REPAIR_REBUILD)
[/sql]

Msg 7919, Level 16, State 3, Line 1 Repair statement not processed. Database needs to be in single user mode.

Error Message:

Msg 7919, Level 16, State 3, Line 1
Repair statement not processed. Database needs to be in single user mode.

Example:
[sql]
DBCC CHECKDB(‘AdventureWorks’, REPAIR_REBUILD)
[/sql]

This error occurs when DBCC CHECKDB command is issued when the database is not in Single user mode.

Fix/Resolution:
Change the database to Sinle user mode and run the query.
[sql]
ALTER DATABASE AdventureWorks SET SINGLE_USER
GO
DBCC CHECKDB(‘AdventureWorks’, REPAIR_REBUILD)
[/sql]

Dont forget to bring the database to the user mode in which it is present before after running the query.

list of dbcc commands in sql server

Following are the list of dbcc commands in sql server 2012
DBCC CHECKALLOC
DBCC CHECKDB
DBCC CHECKCATALOG
DBCC CHECKFILEGROUP
DBCC CHECKTABLE
DBCC TABLE CHECK
DBCC TABLE REPAIR
DBCC ALLOC CHECK
DBCC ALLOC REPAIR
DBCC SYS CHECK
DBCC SYS REPAIR
DBCC SSB CHECK
DBCC CHECKCATALOG
DBCC IVIEW CHECK
DBCC INPUTBUFFER
DBCC SHOWCONTIG
DBCC OPENTRAN
DBCC SQLPERF
DBCC OUTPUTBUFFER
DBCC TRACESTATUS
DBCC PROCCACHE
DBCC USEROPTIONS
DBCC SHOW_STATISTICS
DBCC CHECKALLOC
DBCC CHECKFILEGROUP
DBCC CHECKCATALOG
DBCC CHECKIDENT
DBCC CHECKCONSTRAINTS
DBCC CHECKTABLE
DBCC CHECKDB
DBCC CLEANTABLE
DBCC INDEXDEFRAG
DBCC DBREINDEX
DBCC SHRINKDATABASE
DBCC DROPCLEANBUFFERS
DBCC SHRINKFILE
DBCC FREEPROCCACHE
DBCC UPDATEUSAGE
DBCC dllname
DBCC HELP
DBCC FREESESSIONCACHE
DBCC TRACEOFF
DBCC FREESYSTEMCACHE
DBCC TRACEON