Problem solve Get help with specific problems with your technologies, process and projects.

Recovering a database with just the .ldf and .mdf files

The PC running SQL Server 7.0 crashed. The .mdf and .ldf files of some databases were backed up to another hard disk. I don't know if they did a sp_detach_db because I'm trying to run sp_attach_db to put the databases in the new SQL Server 7.0, but it doesn't work. Is there any way to recover something having just those files (.mdf and .ldf)?

Under the circumstances, with SQL Server 7.0, if the *.mdf and *.ldf files were merely copied to another server, one option may be to perform the following:

  • Install Windows with the same configurations, name, IP address, service packs, hot fixes, drive layout, drive size, etc.
  • Install SQL Server with the same configurations, service packs, hot fixes, etc.
  • Restore the master database.
  • Place the *.mdf and *.ldf files in the same location as the master.dbo.sysdatabases expects.
  • Restart SQL Server to ensure no issues are recorded in the SQL Server error log.
  • Test the application to ensure the application is working properly.
If this is not successful, it may be necessary to restore all of the databases from tape. Based on this issue, it is probably beneficial to plan and implement a high availability and/or disaster recovery solution to prevent an issue similar to this one from causing long-term downtime.

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

my sql server fles change in another txt file .DATA folder all DB  .mdt file open with in paint and .ldf file open in pdf file please give me solution.