Record the recovery process for SQL Server2008 log file corruption

Source: Internet
Author: User

Record the recovery process for SQL Server2008 log file corruption:

Environment: System Windows Server2003

Database SQL Server2008

Failure reason: The user interface is inconsistent when linking the same server through MSTSC. The decision to restart the server, the application is not properly closed (the program is accessing the database), causing the database log file corruption, it is natural to access the MDF file! (all Microsoft's own products, restart the server why can not check the status of the database, set the database in a safe state after restarting it?? Therefore, to develop a good habit. Close the existing database link and restart the server)

Failure performance: Unable to access the data file, just like the following Jd_2 database.

Solution:

1: Delete, or detach the database Jd_2 (you may be prompted to delete or detach the database, you can restart the corresponding DB instance and try again)

2: Create a new database, the log file and the data file name are named as the corresponding file to restore.

3: Set the new database to offline mode, locate the physical path to the new database, and overwrite the existing MDF file with the copy of the MDF file you want to restore.

4: Set the database to online mode, refresh the database, you can see that there is no egg to use.

5: Execute ALTER DATABASE jd_2 set emergency sets the databases to emergency mode.

Perform:

Use master

DECLARE @databasename varchar (255)

Set @databasename = ' Jd_2 '

ALTER DATABASE wisdomagricultureplatform SET single_user//sets the target data base to single-user state

DBCC CHECKDB (@databasename, Repair_allow_data_loss)

DBCC CHECKDB (@databasename, Repair_rebuild)

ALTER DATABASE wisdomagricultureplatform SET multi_user//sets the target data base to multi-user state

6: The database is in emergency mode after the refresh, the data is basically restored. The current data bureau is in emergency mode and cannot be backed up on the database. So we're going to restore emergency mode to normal mode

7: Perform select * from Sys.master_files View database basic and status information

8: Perform select * from sysdatabases to view all database information as follows:

Status code meaning: http://blog.csdn.net/nemo2011/article/details/9233777

Perform:

Scenario 1:

sp_configure ' allow updates ', 1
Reconfigure with override
Update sysdatabases set status=0 where name= ' jd_new '

Change Database status code, prompt not to allow changes =>sql server2008 does not support modifications to system tables

Scenario 2:

For normal undamaged databases, you can use the

ALTER DATABASE dbname SET EMERGENCY

ALTER DATABASE dbname SET ONLINE

Switch between emergency mode and normal mode. However, for corrupted data, it is proven that this method is not feasible.

Reference to some of the online approach, have not solved the problem! Ask a friend to enlighten me ~ ~

Record the recovery process for SQL Server2008 log file corruption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.