sql error 5171- mdf is not primary database file

10
SQL Error 5171- .mdf is not primary database file

Upload: jasonclark03

Post on 20-Jan-2017

669 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: SQL Error 5171- MDF is not Primary Database File

SQL Error 5171- .mdf is not primary

database file

Page 2: SQL Error 5171- MDF is not Primary Database File

Topic Setups Overview - SQL Error 5171 Error Message Recovery Methods to fix Error 5171

oManual Solutions Single file attachment procedure Restore database from .bak file Manual method failure

o Alternate Solution Third party tool

Conclusion

Page 3: SQL Error 5171- MDF is not Primary Database File

Overview ~SQL Error 5171SQL Error 5171 states that MDF file is not primary file. The root cause of this error message is that the database file is corrupt. It may be possible because of various reasons such as: Power surges Human errors Virus infections, etc. 

Page 4: SQL Error 5171- MDF is not Primary Database File

Error Message

Page 5: SQL Error 5171- MDF is not Primary Database File

Recovery Methods to fix Error 5171

1. Manual Solution: (I) Single file attachment procedure(II) Restore database file from .bak file

2. Alternative Solution

Page 6: SQL Error 5171- MDF is not Primary Database File

Single File Attachment ProcedureSingle file attachment process allows you to attach single file one by one to the database Execute sp_attach_single_db stored procedure. Syntax:

Page 7: SQL Error 5171- MDF is not Primary Database File

Restore Database From .bak File This method helps you to restore the database from full backup.

Open SQL Server Management Studio then Right Click on ‘Databases’ and select ‘Restore Database’

Page 8: SQL Error 5171- MDF is not Primary Database File

Manual Solutionso Due to high level corruption, sp_attach_single_db get fails to fix the SQL Error 5171

Sometimes you don’t have a healthy backup to restore database, In such situation, you must have an alternative solution.

Page 9: SQL Error 5171- MDF is not Primary Database File

Third Party Tool

Recover both MDF and NDF file

Recover Deleted SQL Tables Data

Directly export into SQL Server 2014

Quick and Advanced scan option

Support XML Data Type

The SysTools SQL Recovery tool is a secure, trustworthy and result oriented way to recover & restore MDF file.

Page 10: SQL Error 5171- MDF is not Primary Database File

Conclusion Restoration from manual method turns difficult when you don’t have a clean backup of the database and 'sp_attach_db' method won’t work if you do not use 'sp_detach_db' for detaching the same database In such situation you need to have an SQL recovery software like SysTools SQL Recovery, which can easily recover your database