SQL Database is corrupted

5 pts.
Tags:
SQL Database
SQL Server 2005
Respected sir, Unfortunately the hard disk of my system is damaged, now I recovered my database. but it cannot be attached again to SQL management studio 2005. The error is myfile.mdf is not a primary database file. (SQL server, error 5171) Please sir help me.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Corruption
in SQL server database can happen due to any uncertain like virus attack, power
failure, hardware issue, OS malfunction, sudden system shutdown, so on. When a
SQL server data file (.mdf) is corrupt then DBAs can try several methods to
repair and recover data from it. 


  • Run DBCC CHECKDB: It checks & reports all the error message in
    errorlog, if there is any problem with the database. Try to analyze &
    understand the error message logged in the errorlog. Re-run DBCC CHECKDB
    with the recommended minimum repair option to repair the file. 

Detailed information about DBCC CHECKDB is available
here: 
http://www.techrepublic.com/forums/discussions/sql-database-recovery-from-corrupt-database-file/

  • Restore from backup: If above command fails to fix the error
    message the try to restore the database from clean backup. 
  • 3rd party tool: Try 3rd party Recovery Toolbox for SQL Server to
    recover data from corrupt mdf file. Most of the software have demo version
    that shows the preview of corrupt SQL server data file. 

http://www.sql.recoverytoolbox.com/

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • markwillium
    As a resolution to the SQL server error message 5171, you can use 'sp_attach_db' for attaching the database. 

    Note: sp_attach_db won't work, if you do not use 'sp_detach_db' for detaching the same database. 

    Another possible remedy is to use 'CREATE DATABASE' command with the 'FOR ATTACH' clause.
    30 pointsBadges:
    report
  • clark445kent
    Hi,

    I have googled about your query and I have got a article http://www.sqlrecoverysoftware.net/blog/how-to-fix-sql-error-5171.html for it. I hope this is help full for you. 
    3,630 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following