SQL Server database attach error/database cannot attach resolution procedure

Source: Internet
Author: User

Fault Description
In this case, a server store of a brand r520 model with a SQL Server database is included, and this storage contains two sets of disk arrays, with RAID levels of RAID5. Under normal circumstances, the user's SQL Server database is stored in the D disk, after the large amount of data caused by the size of the D disk, the administrator generated a. ndf file in the E-disk and pointed the database path to the E disk to continue to use. But about half a month after the database suddenly failure error, connection failure, SQL Server database can not attach query. The administrator then makes an attempt to recover the data (the administrator has made multiple attempts in the original environment, resulting in repeated changes to the original database file, overwriting, disk space replication), which makes it more difficult for later data recovery to work.

Backing up data

In accordance with the industry practice of data recovery, all data must be fully mirrored before data recovery operations, and the database is instrumented and analyzed using the DD command or the data Recovery tool to mirror all the disks into files.

Fault Analysis

The reason for the database error is a logic error caused by the lack of storage space in the D disk.
The engineer analyzes and reorganizes two sets of RAID5 disk arrays on the storage, views the data and backs up the RAID's total database files for an attempted attach database, but the database reports an error. Error: "Primary database file and secondary database file does not match"

Data Recovery

The data recovery engineer looks at the bottom of the. ndf file, but the amount of data found in the file is minimal and there is little data, and the engineer cancels the association relationship between the. mdf file and the. ndf file, using the. mdf file for additional databases. Error, error content is " The log file (. ldf) and the database file (. mdf) do not match. The engineer continues the database five database attach operation, the database can be attached but the system table is corrupt, the database still does not work properly.
The engineer tried to repair the database system table but did not succeed, the data table was badly damaged, the repair was extremely difficult and the effect was difficult to protect, and the data recovery engineer decided to abandon the repair data table instead of trying other methods.
The data Recovery engineer puts the breach of data recovery on the database record, extracts the database records by a small program of their own, and obtains the table structure of the database based on the database backup data of the client. Refactor the database table structure, and then import the database records into the new table. Data Recovery Success

Database Usage Tips

In the process of database use, it is reasonable to allocate the disk space of the database files and clean up the garbage data in time to ensure the normal and safe operation of the database.

SQL Server database attach error/database cannot attach resolution procedure

Related Article

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.