Skip to main content

Recover a corrupted MS SQL database

I have not tried this, use with caution.

There is a manual solution to fix this problem, but you need to have Microsoft SQL Server Management Studio for that. If you have it, you need to follow the steps given below:
  • Open Microsoft SQL Server Management Studio on your system.
  • Now click on New Query button.
  • A new query page will be opened. Write the SQL scripts (shown below) on the page:
                    EXEC sp_resetstatus [YourDatabase]; 
                    ALTER DATABASE [YourDatabase] SET EMERGENCY  
                    DBCC checkdb ([YourDatabase]) 
                    ALTER DATABASE [YourDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
                    DBCC DATABASE ([YourDatabase], REPAIR_ALLOW_DATA_LOSS) 
                    ALTER DATABASE [YourDatabase] SET MULTI_USER 
  • Now click on Execute.

Obtained from https://semnaitik.wordpress.com/2014/02/22/how-to-repair-corrupted-ms-sql-database-file/

Comments

  1. The above source URL is no longer available. It has been redirected to this new source - http://wordpress.semnaitik.com/2014/02/22/repair-sql-database/

    ReplyDelete

Post a Comment

Popular posts from this blog

NMAP

It's been about 15 years since I used NMAP, I forgot how useful the tool is. To find out what services are running on an IP address simply use something like nmap -n -v -p1-10000 x.x.x.x -n tells nmap not to do name resolution (saves about 13 seconds if the IP you're scanning isn't in DNS_ -v verbose -p1-10000 says scan ports 1 to 10,000 (otherwise nmap will only scan the first 1000 ports)