Created
December 2, 2020 12:44
-
-
Save Ja7ad/29fe115b43665cabdeca19633b91ca61 to your computer and use it in GitHub Desktop.
Find invalid records in your database and remove record, Eventually repair your database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master | |
SELECT NAME,STATE_DESC FROM SYS.DATABASES | |
WHERE STATE_DESC='SUSPECT' | |
USE master | |
"Replace your database name with Your_Database_Name" | |
ALTER DATABASE Your_Database_Name SET EMERGENCY | |
DBCC CHECKDB (Your_Database_Name) | |
ALTER DATABASE Your_Database_Name SET SINGLE_USER WITH ROLLBACK IMMEDIATE | |
DBCC CHECKDB (Your_Database_Name, REPAIR_ALLOW_DATA_LOSS) | |
ALTER DATABASE Your_Database_Name SET MULTI_USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment