Error while attaching Datafiles.

  • Hello

    when we Try to attach the DB files, i can add the first primary datafile(ABC.mdf). when i try to add the next datafile(ABC_1.mdf). It gives me the following error.

    ADDITIONAL INFORMATION:

    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

    ------------------------------

    M:\ABCDATA2\ABC_1.mdf is not a primary database file. (Microsoft SQL Server, Error: 5171)

    Can some one provide me the solution.

    thanks

  • http://msdn.microsoft.com/en-us/library/ms188902.aspx

    investigate the files in you backup....use the link above..

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • Henrico Bekker (12/23/2010)


    http://msdn.microsoft.com/en-us/library/ms188902.aspx

    investigate the files in you backup....use the link above..

    There's no backup here. He's attaching, not restoring.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • What files are supposed to be part of this database?

    When you use the dialog to attach a DB, SQL goes and finds the secondary and log files for you, based on what's in the DB header. You shouldn't need to add files, maybe just change the locations.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • sometmes the .bak file will be corrupted...try attaching another .bak file

  • For database attachment you map all data and log files in one screen.

    Each db has at least one primary data files, and might have secondary data files.

    When you select the primary data file, the wizard will find the secondary and log files.

    So, perhaps you are trying to attach a secondary data file without selecting the primary first.

    Please check How to Attach Database in SQL Server 2011 and How to Attach Database in SQL Server 2008

    I hope that helps,

  • abhishek.8604 (12/24/2010)


    sometmes the .bak file will be corrupted...try attaching another .bak file

    There's no backup here. He's attaching, not restoring.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply