Solved

I have corrupt DB and I'm trying to restore its .BAK file to a DB with the same name.

Posted on 2009-07-14
7
240 Views
Last Modified: 2012-05-07
OK, So I have a corrupt DB in MS SQL Server 2005. I cant load it, so I cant restore to it. I created a DB with its same name. I am pulling down the most recent .BAK file for the corrupt DB, hoping it will allow me to restore it to the new DB. Is this possible or do I need to do something else? Help...
0
Comment
Question by:daunavan
  • 4
  • 3
7 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
Comment Utility
>> So I have a corrupt DB in MS SQL Server 2005.

Do you mean your Database or a database backup. If it is database, then you can repair the database using

DBCC CHECKDB ( ur_db_name , repair_options )

Kindly replace repair_options with any one of the options below
REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD

Kindly note that ALLOW_DATA_LOSS repairs the database by correcting out incorrect records. So you need to be careful on this.

More info below:

http://msdn.microsoft.com/en-us/library/ms176064.aspx

>> I cant load it, so I cant restore to it. I created a DB with its same name. I am pulling down the most recent .BAK file for the corrupt DB, hoping it will allow me to restore it to the new DB. Is this possible or do I need to do something else?

If the database is corrupted and if you have the *.bak files available, then you can delete the current and create the new database right.
Make sure you take a tail backup of existing database (corrupt) so that you wont lose transactions done after you take your backup.

Hope this helps
0
 

Author Comment

by:daunavan
Comment Utility
I can not run SQL commands on it becuse I can not atttach it to the SQL server. How else can I fix a broken DB that will not connect?
0
 
LVL 57

Expert Comment

by:Raja Jegan R
Comment Utility
If your *.bak file is corrupt, then you have to try out some third party tools like this:

http://www.apexsql.com/sql_tools_recover.asp
http://www.red-gate.com/products/SQL_Log_Rescue/index.htm
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:daunavan
Comment Utility
OK, the problem is not with the BAK file. I have corrupt MDF / LDF and it will not load so I can not associate it with the SQL server and therefore can not repair it. I was trying to use a new DB, with its same name, and no data, to then load and try to restore the BAK data to it. But this did not work I am at a loss.
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
Comment Utility
>> I have corrupt MDF / LDF and it will not load so I can not associate it with the SQL server

Then we can handle it...

1. Try to attach the database without specifying the LDF file. If it attaches then the LDF file is corrupt and you will lose only your uncommitted transactions and no issues with it.

2. If it doesn't attach, then your MDF file is corrupt and you can use some third party tools to repair MDF files so that you can restore your database. Please find below the tool which might help you out.

http://www.repairmdf.com/sql-mdf-repair.php

Kindly note that repairing MDF file may or may not loss some data.
Hope this helps
0
 

Author Closing Comment

by:daunavan
Comment Utility
rrjegan17 is a saint!!!! You saved my life and my sanity. I can never thank you enough!
0
 
LVL 57

Expert Comment

by:Raja Jegan R
Comment Utility
Welcome and glad to help you out..
Hope your DB is restored, Up and Running now..
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now