Question

restoring MSSQL DB from .MDF and .LDF (no 3rd -LOG file)

Asked by: freeflight123

Hi,

this morning I discovered that it wasn't possible to make Inserts anymore because there was a  File which grew to > 61GB:
D:\sqldata\MSSQL\LOG\SalesLogix-LOG

which took all the HD space.
I then shut down the SQL Server and deleted this file because I thought it only was an error log file.

Now the Enterprise Manager say "SalesLogix (suspect)" - (no items)

D:\sqldata\MSSQL\data\SalesLogix.MDF and
D:\sqldata\MSSQL\data\SalesLogix_log.LDF are still there

I tried to create a new db in the enterprise manager - the .mdf and .ldf where marked with a green cross, but it also expected to find the -LOG file, which was marked with a red X.

I then tried:
sp_attach_db @dbname = 'SLXTA', @filename1='D:\sqldata\MSSQL\data\SalesLogix.MDF' ( 'SLXTA' as a new database)

and it told me:
could not open new database 'SLXTA'. Create Database is aborted.
Device activation error: the physical file name 'D:\sqldata\MSSQL\data\SalesLogix-LOG ' may be incorrect

- although I renamed SalesLogix.MDF to SalesLogix2.MDF it still seams to have hard references to specific paths...
How can I get the DB back up again - with only using the .mdf and .ldf?
What is -LOG anyways? to create a dummy empty one didn't work.

I also tried:
ap_attach_single_file_db but it insisted on the SalesLogix-LOG again:
device activation eroor: the physical file name 'D:\sqldata\MSSQL\data\SalesLogix-LOG ' may be incorrect

Please help or I'll have to look for a new job... :(
Freddy

FOLLOWUP: There is also a backup, 3 weeks old (too old)

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-07-18 at 14:55:53ID20683368
Tags

mdf

,

restore

,

sql

,

ldf

,

from

Topic

MS SQL Server

Participating Experts
5
Points
500
Comments
31

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. MDF and LDF files.
    Hi. I have a large number of databases on my MS SQL server. There are files .MDF and .LDF files. From what I can tell (and I may well be VERY wrong here), the MDF file is the REAL data. The LDF file are changes yet to be merged into the live data. The databases are either ...
  2. MDF/LDF File
    I accidentally deleted the LDF file. Now I can't access the database. What can I do? Can I generate the LDF from the MDF? Also, the MDF and LDF continous to grow bigger and bigger. How can I control them? If I limit the LDF size, the old transactions log will be deleted autom...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: nigelrivettPosted on 2003-07-18 at 16:36:28ID: 8956065

I suspect that the file you deleted is a second file created to allow extra space for the database.
If it was a data device then you are probably stuck as you won't be able to recover the data.
In fact I think it must be a data device otherwise it wouldn't be giving that error - which is presumably comming from the filegroup record.

 

by: freeflight123Posted on 2003-07-18 at 16:41:20ID: 8956085

why the hell grew it to 61GB? the last backup was about 19MB or so, it only has 4k accounts.
There is an other 500 points for the one helping me to get the data back (1000 points total)

 

by: freeflight123Posted on 2003-07-18 at 16:45:48ID: 8956098

is there a way to get something back with the old 3 week old backup and then to add the .ldf to it (or so)? some tables have changes since then, though...

 

by: arbertPosted on 2003-07-19 at 10:05:29ID: 8958836

Yes--check out :

http://support.microsoft.com/default.aspx?scid=kb;en-us;253817



It tells you how to use a newer log file against an old MDF.

 

by: arbertPosted on 2003-07-19 at 10:06:17ID: 8958841

Also, don't every just go deleting and renaming database files--not a good idea...........That's why there are system utilities to do such operations.......

 

by: nigelrivettPosted on 2003-07-19 at 14:24:13ID: 8959765

If you have the database in full /  bulk logged recovery mode and have the sequence of log file backups from the full backup and have not done anything to upset that sequence (truncate log, change recovery models, ...) then you can restore the backup with no recovery and restore all the sequence of log backups then recover the database.

If you violate the conditions above then you can't.

 

by: freeflight123Posted on 2003-07-19 at 15:31:12ID: 8959899

hi nigelrivett:
I have:
a .MDF (99 MB)
a .LDF (4.2 GB)

the last backup, 3 weeks ago
nothing was changed... how do I do it?

 

by: arbertPosted on 2003-07-19 at 16:24:27ID: 8959991

Except it appears a secondary file was added to the log--that's the file you deleted.....

 

by: dba123Posted on 2003-07-19 at 21:25:44ID: 8960660

This may help you figure out how to restore the MDF from my disaster recovery doc from work:

Step 1 – Restore the full backup of the base database through a full database restore.

1.      In SQL Enterprise Manager, right-click on the database and select All Tasks | Restore Database
2.      In the Restore Database screen, select the “Master” database, and the database radio button
3.      Select the backups to restore from the Restore column…select the BAK file to restore the full Master database which is found in C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP and select the latest Master BAK full backup file possible
4.      Press OK, and then OK again to restore the database

NOTE: If the database has not been created yet, the restore utility will allow you to specify the database name to restore as and will actually create the database for you and also restore it.  Simply put the name of the database that has not been created yet in the field for “Restore as database”

 

by: dba123Posted on 2003-07-19 at 21:26:25ID: 8960662

of course on your case for # 2 you wouldn't be using the master DB

 

by: freeflight123Posted on 2003-07-19 at 23:27:12ID: 8960910

dba:OK, then I would restore a 3 week old backup... can I add do something with the current .LDF or MDF to get it more up to date?

 

by: NguyenHuyPosted on 2003-07-20 at 03:30:51ID: 8961262

You might try to delete the LDF (make a back up for it first) then attach MDF only. From my past exp, SQL Server creates a new LDF file for it and things work fine since LDF is just the log file. Try to see your luck

 

by: dba123Posted on 2003-07-20 at 08:33:23ID: 8962020

Few questions:

Were you able to view the tables at all in the database.....I mean could you expand that green X to see the tables within that databse?

Here is some background info:

Every SQL Server database has a transaction log file (ldf).  A transaction log is a history of modifications to the database, and SQL Server uses it to maintain database integrity.  Any changes to the database are written to the transaction log first and then changes are applied to the database.  Then, if the database update is successful when  person adds a record or updates a record in the databse, the transaction is completed and recorded successfully.  If any updates fail, then SQL will use the transaction log to restore the database to its original state (called rolling back the transaction).  This allows you to restore the database in case there is an earthquake, power outage, or whatever when you tried to enter a transaction.  This is straight from a good book you might want to purchase that I use a lot called "SQL Server 2000 Administrator's Pocket Consultant" written by Microsoft.


I would actually create a test database first in SQL enteriprise manager then try to restore the MDF to it and see if that works.  I don't think you will be able to get it more up-to-date then the 3 weeks you talk of unless you have the latest  .LDF I think.

I have to go on a trip but let me know on the first question I asked....

 

by: dba123Posted on 2003-07-20 at 08:36:34ID: 8962030

Try this book also, very very good and one that I helped use to create my disaster recovery documentation for our servers:
Admin 911 SQL Server 2000

I am new to disaster recovery so I only know the basics here but I think you are out of luck trying to get it back to the latest and greatest data unless you have the MDF and LDF that is dated the day you deleted that file.

 

by: dba123Posted on 2003-07-20 at 08:44:44ID: 8962059

By the way, your only recent MDF backup is 3 weeks old?  That is a mistake in itself.  Don't you have any incremental backups?

 

by: dba123Posted on 2003-07-20 at 08:50:32ID: 8962087

Sorry, I didn't meant to criticize you on the backups but whoever is setting them up needs to be sure they do imcrementals as well as full backups for each major database each week to be more safe.  That is all I have right now until I get back from my trip.  Good luck

 

by: arbertPosted on 2003-07-20 at 10:55:00ID: 8962551

"From my past exp, SQL Server creates a new LDF file for it and things work fine since LDF is just the log file. "


Just the log file?  If you guys don't understand the workings--don't respond.....

 

by: dtoddPosted on 2003-07-20 at 17:24:31ID: 8964058

Hi Freddy,

You seem to have a couple of things mixed up.

sp_attach attaches exisiting databases - it may create a new log file for you.

You can't create an empty dummy log file by itself.

Creating a database where the filenames are the same as existing files is probably not a good idea.

So try attaching the existing mdf file - I'd suggest that you create a new directory and copy it there. That may allow SQL to create a new log file for you. If the path is there and giving errors then move the existing log file to another directory.

arbert is perfectly correct - while the .ldf is just the log file, there is more to the log file than that.

But try the sp_attach on a copy of the database and let us know how it goes.

Regards
  David

 

by: freeflight123Posted on 2003-07-21 at 09:33:03ID: 8968840

hi all, thanks for all the comments.

dba: I have the 3 week old backup _and_ the most current .ldf - would that work out? how would I have to go ahead?

all tries to attach just the .MDF failed with 'device activation error' - it expected the .ldf AND the SalesLogix-LOG file.

 

by: arbertPosted on 2003-07-21 at 09:36:41ID: 8968863

I thought you deleted off one of the ldf files????

Brett

 

by: freeflight123Posted on 2003-07-21 at 09:44:19ID: 8968922

I deleted the SalesLogix-LOG (which might be an extension/an other .ldf file - I am only guessing at this point, it's under /logs/)

There is still:
the 3 week old backup
the .MDF
the/one .LDF

 

by: dba123Posted on 2003-07-21 at 09:45:01ID: 8968925

Unless anyone else in this forum has anything to add to your latest question, I would just create a test database and call it the same name as your troubled database but with a digit on the end.  Then restore your last mdf (from 3 weeks ago) to that test database.  Then, open the test database and do some queries just check if most of the data is in there.  After that, delete your database that you had problems with and rename the test one to be named with the exact same name as your troubled database and then hopefully if the name is the same, all should maybe check out.  Give it a try, this is about all I can provide.

 

by: freeflight123Posted on 2003-07-21 at 09:50:46ID: 8968970

dba: If I do this, then I'll get a database with the data from the backup only - or did I miss something?
how can parts of the .LDF check out?

 

by: arbertPosted on 2003-07-21 at 10:01:30ID: 8969059

You cannot do "Parts of the .ldf" since you possibly deleted file2 of a 2file ldf.  However, you can look at lumigent logexplorer and possibly restore the 3week old file and the "scrounge" the data off part of your ldf (http://www.lumigent.com).

Brett

 

by: dba123Posted on 2003-07-21 at 11:14:54ID: 8969587

I am not sure about the ldf file and how you can retreive any information from it, try albert's suggestions for this part.....sorry

 

by: dba123Posted on 2003-07-21 at 11:15:59ID: 8969592

What I was thinking is that you would only get what info is in the MDF, and that you were out of luck trying to get anymore back beyond 3 weeks trying to use the ldf.....since I don't know much about restoring data from an ldf, that was my only suggestion, using the straight MDF only and whatever info is in that verision of the database.

 

by: dtoddPosted on 2003-07-21 at 12:12:23ID: 8970045

Hi,

If I can hazzard a slightly unhelpful guess or two
1. I'd suggest that SQL was stopped when the SalesLogix-LOG file was deleted, and since the database wasn't detached cleanly attaching it could be a bit of a problem.

2. The SalesLogix-LOG may have been a log file, but at this distance it is almost as likely to have been a data file ... no?

Suggestion: Have you tried to recover the deleted file? Nortons or somethign similar? As deleted files are recoverable for only so long try this next ... then try to reattach all three files. Then apply dbcc shrinkdb and dbcc shrinkfile to recover extra space in the data and log files. (Shrinking log files is a perinal topic I'm sure the PAQs will have heaps of help there)

Otherwise it looks like the best you are stuck with 3 week old data ... sorry.

Regards
  David

 

by: freeflight123Posted on 2003-07-21 at 14:38:11ID: 8971259

Hi, big THANK YOU to everybody who helped me!
I tried to split the points as fair as possible - you guys are just incredible!
M$ finally was able to get the most current data out of it - I don;t know how exactly (yet) they did it.
our sysadmin recorded the session... hope to see/learn about it soon.
I learned _my_ lesson: never just delete a file - even if it seams to be a 'log file' only and even if 20 people are in your office complaining... pressuring you to 'fix' it.
It's not only just 'data' in a database - it's the work of many people.

Big,Big thank you to arbert especially, thanks Brett!

 

by: arbertPosted on 2003-07-21 at 15:39:33ID: 8971580

Glad you got it.  Like I told you the other day, it might cost to call Microsoft, but they do have access to more tricks at getting data back than us little people.

Brett

 

by: freeflight123Posted on 2003-07-21 at 15:53:20ID: 8971654

that's why you received the most points, Brett ;)
They uploaded some kind of (big) tool - DSL was slow for half an hour - I was to 'scared' to watch them at this point, but will have a look at the recorded session later... with a cold beer in my hand, I definitely need that... yeah!

 

by: arbertPosted on 2003-07-21 at 15:56:45ID: 8971672

Well, I hope you didn't fret about it too much over the weekend!  Have a cold one for me too--been a typical Monday!

Brett

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...