Incorrectly marked database in the Microsoft SQL server

How can this be repaired?

Reasons for the problem and steps of a correct recovery procedure.

Subscribe to our newsletter

Reasons and procedure

Anyone who works with databases in the MS SQL server is certainly familiar with this problem. After an unexpected event, a database can no longer be reached and is marked as suspect. The reasons for this can be manifold:

  • The database is corrupted (marked as "corrupt").
  • There is not enough memory for the SQL server to restore the database at start-up.
  • The database cannot be opened due to insufficient memory or hard disk space because of defective files.
  • The database files are locked by the operating system, third-party backup software, etc.
  • An unplanned termination of the SQL server service, a power failure or a hardware error.
To be able to edit the database again, the following steps must be carried out:

  • Open Microsoft SQL Server Management Studio.
  • Establish a connection to the affected SQL server instance
  • Open a new query
  • Copy the following script into the query and replace
    "[defective database]" with the name of your database marked as defective.
    database.
  • Run the query [vc_single_image image="10521" img_size="full"]
Afterwards, the database can be used again to its full extent. It should be noted that inconsistencies may occur due to data loss. But here the following principle applies: an existing backup has never hurt anyone.

Subscribe to our newsletter

Subscribe to our biannual newsletter and stay up to date.

* Mandatory field