There are no definite criteria when errors will occur. A database administrator may suddenly be prompted with errors in the SQL database or experience data loss. It is because of the factors affecting SQL server database. A wrong query executed by user may generate error or closing database when it is working state. One should be prepared for such errors and their recovery method.
An instant and effective way of SQL database recovery is DBCC CHECKDB command. This command is used to repair and rebuild corrupt SQL database and to get back deleted MDF, LDF files.
  • Login to the SQL Database in which error has occurred
  • Start the database console to execute commands for database repair
  • First, type DBCC CHECKDB command and know the status of database
  • Check the Database Index ID, if the index ID is greate than 1, then recreate the database
  • If Database ID is between 0 and 1 then run the below given commands for database recovery
  • DBCC CHECKDB (Database Name repair_fast) for instant recovery
  • DBCC CHECKDB (Database Name repair_rebuild) to recreate and rebuild the SQL database
  • DBCC CHECKDB (Database Name repair_allow_data_loss). These commands are used when the above two are not useful. Here user agrees for data loss in order to make the database run

They are useful for quick and instant recovery of database files.