Results 1 to 8 of 8

Thread: Corrupted mdf

  1. #1
    Join Date
    Jun 2007
    Posts
    6

    Unanswered: Corrupted mdf

    Hi Everyone,

    when i am trying to attach a 'xxx.mdf' file it is showing message 'xxx.mdf' is not a primary database file.

    Please suggest me what could be the reasons and what are the possible ways to recover my database.

    I have lot of important data in the database.

    Thanks and Regards,
    Shashidhar

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    We need substantially more information here.

    What version of SQL?
    What OS?

    How did the file become detached in the first place (deliberate action, a download, or was it recovered from some where?)

    Is is possible that the file is one of multiple files belonging to a single database?

    Where is the log file?

    What is the precise error message you are getting?

    Did you google that error message?

    And, if it's got so much valuable information, where's your backup?

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Go back to the server that this database was detached from. If you only copied the files, as opposed to moving them, you should be able to find all the files needed for the database. The error message means that SQL Server can not find the system tables in the file you listed first in the sp_attach_db statement. If you have multiple data files (as I strongly suspect from the error message), try changing the order of them in the sp_attach_db statement.
    Lesson for the future: Always write down the order of the files BEFORE attaching them.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I would say it's not a primary database file
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Aug 2006
    Location
    San Francisco, CA
    Posts
    136
    Correct me if I am wrong but isn't the mdf file always the primary database files and the ndf is secondary?

  6. #6
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Consider yourself corrected. The file extension is only suggested, and in no way means that a file is a primary or secondary file. You can make all of your files MDF, NDF, LDF, or even BOB.

  7. #7
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by MCrowley
    ... or even BOB.
    BOB. I like BOB.


    Regards,

    hmscott
    Have you hugged your backup today?

  8. #8
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I think I might prefer LongTallSally
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •