MS SQL Server is the best and ultimate storage for the users who need to deserve their database secured from unknown entity. The SQL Server allocates large size database file in it which makes easier to his client whenever they requested. But due to undesirable condition like power supply fluctuation the machine hardware components like hard disk which is storage house of the crucial database files got damaged and hence distorted the whole existing data and information. The mentioned reasons are valid and responsible for generating SQL server error 5171. Whenever user faced such situations they tried to solve it by some well result oriented methods as a result they got succeed but when they attach his MDF file to the SQL Server databases an error ".mdf is not a primary database file. (microsoft sql server error 5171)" rises. The prototype of the error code 5171 is like this:
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "filename.mdf". Operating system error 5:
Let us discuss how to solve MS SQL error 5171 & 5120 when MDF file unable to attach to the databases.