Skip to content

Instantly share code, notes, and snippets.

@haroldcris
Last active January 21, 2022 19:05
Show Gist options
  • Save haroldcris/966841d514c2596a6261ae78d4d99401 to your computer and use it in GitHub Desktop.
Save haroldcris/966841d514c2596a6261ae78d4d99401 to your computer and use it in GitHub Desktop.
MS Sql Recover from CheckDb Error
> To Check Run
DBCC CHECKDB ([DATABASENAME] ) WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY
> To Fix
ALTER DATABASE promis
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
DBCC CHECKDB (promis, REPAIR_REBUILD ); /**OPTIONS: repair_rebuild OR REPAIR_ALLOW_DATA_LOSS **/
GO
ALTER DATABASE promis
SET MULTI_USER;
>>>>>
Get Error Page Number and Run
DBCC TRACEON (3604)
DBCC PAGE ('DatabaseName', 1, [PageNumber] , 3)
> Copy Result to Note Pad.
> Look for Invalid world to find the AutoId
Resources:
https://sqlserverpowershell.com/2014/03/10/fixing-dbcc-check-error-2570/
@haroldcris
Copy link
Author

To Fix:
You can use DBCC CHECKDB (promis, repair_rebuild)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment