Attaching mdf and ndf from sqlserver 2000

CSE Teacher 21 Reputation points

Hi folks!

I've an old sql2k database with mdf and ndf files I remember that the ndf files were created as secondary files on a partition different from the mdf. I have the files in a backup archive and want to put together the files and access the data. I Installed win2k3 server, sql2k, text editors, etc. Attaching the mdf file in the sql server brings up the db but does not ask for ndf files. Seemingly everything works but I know that I had much more data. I think they reside in the ndf files which are not loaded. Please help me to get all my data back in a single database. Thank you very much!

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,273 questions
0 comments No comments
{count} votes

Accepted answer
  1. Seeya Xi-MSFT 16,411 Reputation points

    Hi @CSE Teacher ,

    Primary file contains startup information for the database and points to the other files in the database. Every database has one primary data file. The recommended file name extension for primary data files is .mdf.
    So, although the interface you see is like this, you can see your secondary data file in the box below.
    I did a test. I deleted the secondary data file, and then I added the main data file, you can see:
    Therefore, as long as you are in the normal attach process and do not see any wrong information, the attach is successful.

    For more information, please see:
    Database Detach and Attach (SQL Server)
    Attach a Database
    AND Different methods to attach SQL Server MDF files.
    The last link contains some screenshots, which are helpful for understanding, so I also posted it.

    Best regards,

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Olaf Helper 38,941 Reputation points

    In the primary database file all system informations are stored, also with database (secondary) files belongs to the database.
    If you attach the database and the database engine isn't complaining about missing NDF files, then because the NDF do not belong to the database.

    Have you check the database properties => Files to see if SQL Server attached the NDF as well?

    Please note, SQL Server 2000 is out of support since aeone.

    0 comments No comments

  2. CSE Teacher 21 Reputation points

    Thank you for the quick reply,
    Yes, I checked the files and filegroups in the database properties. The ndf files are not there.

    0 comments No comments

  3. Erland Sommarskog 98,911 Reputation points

    You can try this query:

    SELECT 'SELECT COUNT(*) FROM ' + quotename(name)
    FROM   sysobjects
    WHERE type = 'U'

    Copy and paste the result. If that batch runs without errors, you have all data there is in this database.

    Which I think you have anyway, because as I recall, I don't think SQL 2000 permits a partial restore of only some files..

    Maybe these ndf files belonged to another database. Maybe one of them was incorrectly name .ndf, despite that it was a primary file. (SQL Server has no hard rules on the file extension:)

    0 comments No comments