Posted on

CHECKDB REPAIR_REBUILD

use master
go

DBCC CHECKDB (thedb) WITH ALL_ERRORMSGS, NO_INFOMSGS;
GO

ALTER DATABASE thedb
   SET AUTO_UPDATE_STATISTICS_ASYNC OFF;
GO

ALTER DATABASE thedb
   SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO

DBCC CHECKDB (thedb, REPAIR_REBUILD) WITH ALL_ERRORMSGS;
GO

–DBCC CHECKDB (thedb, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
–GO

ALTER DATABASE thedb
   SET MULTI_USER;
GO

CHECKPOINT;

Posted on

logical page errors

–Msg 605, Level 21, State 3, Line 13
–Attempt to fetch logical page (1:3418) in database 16 failed. It belongs to allocation unit 25896092997713920 not to 72057594982891520.

dbcc traceon(3604) –3604 = redirect error output to client instead of log
dbcc page(16,1,3418,1)  –dbid, fileid, pageid, level 0-3
dbcc traceoff(3604)

Posted on

dbcc traceon/traceoff

dbcc traceon(302) redirects output to client rather than logs.  dbcc traceon(302) is often used in conjunction with dbcc traceon(310), which provides more detail on the optimizer’s join order decisions and final cost estimates. dbcc traceon(310) also prints a “Final plan” block at the end of query optimization. To enable this trace option also, use:
dbcc traceon(3604, 302, 310)
To turn off the output, use:
dbcc traceoff(3604, 302, 310)