• matthew_weatherholt - Thursday, May 10, 2018 3:31 AM

  • I had a problem. While working in MS SQL Server was made to emergency restart the computer. After reboot tried again to run the file, but nothing happened. There is a possibility of damage to the database, the program marks the file base in gray. The format of the file is mdf. What to do? Is it possible to get well?
  • In MS SQL Studio run new query:
    1. dbcc checkdb(‘DB-NAME’) with no_infomsgs
    DB-NAME is a name of your corrupted database. If this is completed without any errors then the database does not need to be repaired.
    2. Alter database DB-NAME set SINGLE_USER
    Before we begin repairing the database, the database must be set in single user mode.
    3. dbcc checkdb(‘DB-NAME’,REPAIR_REBUILD)
    There are number of repair model usually we use first REPAIR_REBUILD. When everything is ok go to step 5.e (multi user mode) If not, go to next step.
    4. dbcc checkdb(‘DB-NAME’,REPAIR_ALLOW_DATA_LOSS)

    you don't know how to repair corrupted MS SQL Server database? 
    This command may cause data loss. When everything is ok go to step 5.e (multi user mode) If not, go to next step.

    5.
    a. ALTER DATABASE DB-NAME SET EMERGENCY
    b. ALTER DATABASE DB-NAME SET SINGLE_USER
    c. DBCC CHECKDB (DB-NAME, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS
    d. ALTER DATABASE DB-NAME SET ONLINE
    e. ALTER database DB-NAME set MULTI_USER

    Description:
    a. Set database to emergency mode
    b. Set database to single user mode
    c. Check database and repair with allow data loss
    d. Back database to online mode from emergency mode
    e. Set database to multi user mode for normal use
    or you can try to use this service