Error attaching MdxStepByStep.mdf for SQL Server 2008 MDX Step by Step.

  • When I try to attach the MdxStepByStep database I get the following error:

    One or more files do not match the primary file of the database. [...] If this is an existing database, the file may be corrupted...

    I tried to find another file. It could be that it is the wrong version?

    I'm running SQL Server 2008 R2.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • When you attach, explicitly remove the ldf in the dialog (if they didn't provide it). Or use CREATE DATABASE ... FOR ATTACH_REBUILD_LOG

    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
  • Thanks.

    I executed the following

    but it is trying to attach the log file.

    How do I force it to ignore the log file?

    CREATE DATABASE MdxStepByStep

    ON (FILENAME = 'D:\MSSQL\MdxStepByStep.mdf')

    FOR ATTACH;

    sg 5173, Level 16, State 1, Line 1

    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.

    Log file 'C:\Microsoft Press\MDX SBS\Setup\SQL Server\MdxStepByStep_log.LDF' does not match the primary file. It may be from a different database or the log may have been rebuilt previously.

    Msg 1813, Level 16, State 2, Line 1

    Could not open new database 'MdxStepByStep'. CREATE DATABASE is aborted.

    When I tried attaching in SSMS and removing the log file I got an error. The Log file does not match the primary file.

    Thanks again.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Here is the link to the download.

    I used the CD that came with the book.

    http://examples.oreilly.com/9780735626188/

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Welsh Corgi (6/17/2012)


    Thanks.

    I executed the following

    but it is trying to attach the log file.

    How do I force it to ignore the log file?

    GilaMonster (6/17/2012)


    Or use CREATE DATABASE ... FOR ATTACH_REBUILD_LOG

    and rename the existing log file if it's there

    Dialog used to allow removal of the log. No enthusiasm to poke at it tonight

    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
  • I missed the:

    FOR ATTACH_REBUILD_LOG;

    I tried it and still got the same error.

    I not sure how I should go about renaming the log in T-SQL Syntax.

    Thanks.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Welsh Corgi (6/17/2012)


    I missed the:

    FOR ATTACH_REBUILD_LOG;

    I tried it and still got the same error.

    The attach just specifies only the mdf? Can't rebuild log if you're specifying the log.

    I not sure how I should go about renaming the log in T-SQL Syntax.

    Open Explorer, find file, right click-rename.

    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
  • I renamed the file and I get an error that the file does not exist.

    I have never had so much trouble attaching a Database even when missing the log file.

    What happens if you download the file in the link that I provided and try and attach?

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Welsh Corgi (6/17/2012)


    I renamed the file and I get an error that the file does not exist.

    What, in explorer when you rename the file you get an error?

    What happens if you download the file in the link that I provided and try and attach?

    Haven't tried.

    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
  • GilaMonster (6/17/2012)


    Welsh Corgi (6/17/2012)


    I renamed the file and I get an error that the file does not exist.

    What, in explorer when you rename the file you get an error?

    What happens if you download the file in the link that I provided and try and attach?

    Haven't tried.

    I get the error after renaming the file in Explorer when I attampt to run the script listed above to attach.

    If you download the files and attampt to attach you will see what I mean.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • What is the exact script you are using?

    Why don't you contact MS press or the author and ask them for a working DB?

    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
  • GilaMonster (6/17/2012)


    What is the exact script you are using?

    Why don't you contact MS press or the author and ask them for a working DB?

    This is one of the scripts.

    CREATE DATABASE MdxStepByStep

    ON (FILENAME = 'D:\MSSQL\MdxStepByStep.mdf')

    FOR ATTACH_REBUILD_LOG;

    I got the Database from the CD.

    The script that I provided is the same as in the CD.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • And what is the exact error message you get running that?

    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
  • I looked up the reviews on Amazon and the solutions that the author provided did not work.

    It is a hassle.

    This is the exact error:

    Msg 5173, Level 16, State 1, Line 5

    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.

    Log file 'C:\Microsoft Press\MDX SBS\Setup\SQL Server\MdxStepByStep_log.LDF' does not match the primary file. It may be from a different database or the log may have been rebuilt previously.

    Msg 1813, Level 16, State 2, Line 5

    Could not open new database 'MdxStepByStep'. CREATE DATABASE is aborted.

    If you download the files you will see what I mean.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • All I can suggest is contact the author and/or MS Press and complain/ask for a working DB.

    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 15 posts - 1 through 15 (of 19 total)

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