recover data from mdf files (ndf being missing)

心已入冬 提交于 2019-12-20 04:50:34

问题


Our client's server got corrupted and the drives containing NDF and LDF files were gone. The only drive that survived was the one with MDF files.

There were no backups of any sort. They recovered the database, which I know just a gist of, by creating new database (from a old database, I guess) and applied bcp utility to copy data over to the new one. But, they would not release the information how they actually recovered.

So, I was just curious to find how it is possible to recover data from MDF files only, when the NDF files are lost/missing.


回答1:


You will need to restore your database by using sp_attach_single_file_db system stored procedure. Something like this...

USE [master]
GO

EXECUTE sp_attach_single_file_db @dbname='DB_Name',
@physname=N'C:\Path_To_Your_MDF_FILE\DB_Name.mdf'
GO

Edit

USE [master]
GO

CREATE DATABASE DB_Name
ON (FILENAME = N'C:\Path_To_Your_MDF_FILE\DB_Name.mdf') 
FOR ATTACH ;
GO



回答2:


To recover data from MDF files only, when the NDF files are lost/missing.

You can use SQL Database Recovery Tool Repairs

I had a database file (Diamond.mdf) which was corrupted and I was not able to attach into SQL Server DB and which contains most of the business data. I was no idea about the error and unable to recover the corrupted DB. I did so many manual mechanism to overcome this issue but unable to do.

  • Select MDF file: Open Select Database dialog box by choosing Select Database icon from File Menu. In Select Database dialog box, click Browse.
  • Open dialog box will appear. Browse and select the desired file and then click Open and Select 'Include Deleted Records' check box to recover deleted records (if found) during the repairing process.
  • Open Select Database dialog box by choosing Select Database icon from File Ribbon. From Search section, select the drive you want to search for MDF files. Click OK.

  • After the search is finished, a list of MS SQL Database files found in the selected drive is shown. Select file you wish to repair from this list and click Repair button to start the repairing process.

  • After the search is finished, a list of MS SQL Database files found in the selected drive is shown. Select file you wish to repair from this list and click Repair button to start the repairing process.

  • This will repair your corrupted mdf file and load the database object on left side pane. In that, we can view all the tables, stored procedure and all objects.
  • After you complete the repairing process successfully, Stellar Repair for MS SQL shows preview of corrupted database files. The left pane displays list of items (Tables, Views, Synonyms, Defaults, Data Types and more) in a tree like structure, upper right pane displays the contents of the item selected in the tree view and bottom pane shows message log. A sample screen is displayed below

  • After the repairing process gets completed, click Save option from File ribbon. Specify whether you want to save the repaired database in MDF, CSV, HTML or XLS format by selecting the appropriate radio button. Saving repaired database as MDF Saving repaired database as CSV, HTML or XLS If you want to save your repaired database as an MDF, you can either save your database as a New database or you can insert the data to an existing Live database.
  • To save the repaired database as a completely New database, follow the steps mentioned below: Select New Database radio button. Enter Server / Instance Name. Choose the Authentication method from the drop down list for logging in to the server.
  • If the authentication method selected is Windows Authentication, you need not enter any user name and password. Enter the server user name and password, if the selected authentication method is SQL Server Authentication.

  • Select a destination for saving the repaired MDF file. Click Save button to save the repaired MS SQL Database file. A message is displayed after the process is completed successfully.

  • The repair was completely done and I was able to open the database from SQL Server Db as below.

Note: This is not free tool.



来源:https://stackoverflow.com/questions/21639534/recover-data-from-mdf-files-ndf-being-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!