Detach db failed

  • TITLE: Microsoft SQL Server Management Studio

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

    Attach database failed for Server 'devServer. (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00 & EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

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

    ADDITIONAL INFORMATION:

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

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

    One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=5173&LinkId=20476

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

    BUTTONS:

    OK

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

  • From the error description, it looks like the Database Files (Set of Database Files) are not matching and system cannot continue to attach the Database.

    So check and make sure all the database files exist at the location they are supposed to exist in.

    By the way the Post Name should have been Attach DB Failed


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • files are there

  • Are they all part of the same database? The error says that you've got some files from one database, some files from a different database and you're trying to attach them as a single DB. That'll never work.

    What's the attach command that you're using, what was the structure (file/filegroup) of the database that was detached?

    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
  • 1. Are you selecting the correct .mdf and .ldf to attach?

    2. Does the name of the database already exists in devServer?

    3. Did you recheck the location of the .mdf and .ldf files?

    If all the above things are fine then it should work.

    If not just try out the GUI and attach the DB by selecting the location of the .mdf and .ldf files.

    Thanks,

    Xavier

  • K Xavier (11/18/2009)


    If not just try out the GUI and attach the DB by selecting the location of the .mdf and .ldf files.

    Thanks,

    Xavier

    While attaching the Database from SSMS, you need to select the .MDF File only which will identify automatically the location of the .LDF and additional .NDF Files if they exist.

    I guess, one or more of the additional files are not existing in the required location or have been moved.


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

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

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