SQL 7.0 Restore with only *.mdf and *.ldf

Posted on 2003-03-26
Medium Priority
Last Modified: 2008-03-17

I wonder if its possible to restore a databas if I only have the *.mdf and *.ldf file in Microsoft SQL 7.0. If I'm using the *.bck file I will lose a month of work...

Question by:andreasjn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 23

Accepted Solution

adathelad earned 300 total points
ID: 8209487
You can just attach a database if you have the MDF and LDF files.

This example shows how to attach the pubs sample database that comes with SQL. Just swap in your database name, and set the mdf and ldf file locations to your database ones.

EXEC sp_attach_db @dbname = N'pubs',
   @filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
   @filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'


Expert Comment

ID: 8215075
here's another solution:

Create the database you want. Ex: MyDb

then stop your SQLSERVER

move the mydb.mdf and mydb.ldf in your data directory to a temp directory.

Take your "original" mydb.mdf and mydb.ldf and copy them in your data directory

Restart your SQLSERVER

I know it might not be the better solution, but it saved me once...


Author Comment

ID: 8216501
Hi again!

I did as adathelad said and it worked fine. Thanx for the support. You have saved my day!



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question