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
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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

616 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