The windows got crashed and we copied the file from hdd to other machine..... Let me explain you ..

We have this db since many years one day the c:drive got full so the dba make changes and create new log and mdf in different drive which will save the ongoing data and old data will remain in C:\

we are also able to get old and new data through one DB only. Now machine/windows got crashed and we copied the file into another system/server. We are able to restore the c:drive mdf but other drive mdf giving error it is not a primary database file. Please Help Thanks

I have a database which have multiple MDF files and one log file.

  1. database.mdf
  2. database_log.ldf both files are in c drive.
  3. database.mdf which is in another E drive

Now, When I am attaching the database.mdf(mentioned in point 1) is attaching but the database.mdf which is in another drive is not appearing.

enter image description here

enter image description here

  • Did you try to attach the database with CREATE DATABASE? Example: CREATE DATABASE MyAdventureWorks ON (FILENAME = 'C:\MySQLServer\AdventureWorks_Data.mdf'), (FILENAME = 'C:\MySQLServer\AdventureWorks_Log.ldf') FOR ATTACH; Jun 17 at 11:43
  • 1
    FWIW, you should probably use a different name for the second MDF file and really shouldn't even use MDF as the extension for other files other than the primary to follow best practice standards. I'm guessing you're hitting a limitation (bug) in SSMS though and will need to manually script it, like Eric mentions.
    – J.D.
    Jun 17 at 12:09
  • @J.D. I have try to add the 2 mdf file with same and different name but ....when adding the other MDF file it is giving error mdf is not a primary database file. Jun 17 at 12:20
  • @EricPrévost Yes tried Jun 17 at 12:21
  • 1
    @DominiqueBoucher It actually is possible to name a secondary data file with the .MDF file extension, or any other or no extension, it's just not usually recommended.
    – J.D.
    Jun 17 at 19:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.