Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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

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
daunavan
Asked:
daunavan
  • 4
  • 3
1 Solution
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
>> 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
 
daunavanAuthor Commented:
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
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
daunavanAuthor Commented:
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
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
>> 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
 
daunavanAuthor Commented:
rrjegan17 is a saint!!!! You saved my life and my sanity. I can never thank you enough!
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Welcome and glad to help you out..
Hope your DB is restored, Up and Running now..
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now