sagar pant
sagar pant

Reputation: 357

recover data from mdf files (ndf being missing)

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.

Upvotes: 1

Views: 2257

Answers (1)

M.Ali
M.Ali

Reputation: 69564

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

Upvotes: 1

Related Questions