Home » Topic » SQL Server log file does not match the primary file

SQL Server log file does not match the primary file

Andrew Jackson ~ Modified: July 1st, 2015 ~ ~ 1 Minute Reading

Home Forums SQL Server log file does not match the primary file

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #292 Score: 0
    Andrew Jackson
    Moderator
    1 pt

    Hi,
    I have a question regarding the error “log file does not match primary file”. last month, in SQL Server 2008 r2 databases was moved to a 2012 server. One of two moved it by either restored .bak or copied .mdf & .ldf & attached, but I choose second one. This past Sunday the server rebooted at 6:18am, not a planned reboot, immediately after the database became “inaccessible” and the error “log file does not match primary file” was in the log.

    Please help me to out of this

    #313 Score: 0
    Lincoln Burrows
    Moderator
    16 pts

    Please posts your errors message from the SQL Server Error Log to analyze your error in more sophisticated way.

    #318 Score: 0
    Andrew Jackson
    Moderator
    1 pt

    Hi
    The below Error MSGs I got

    Error: 5173, which shows “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”

    Error: 17207, Severity: 16, State: 1.
    FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.) occurred while creating or opening file ‘x:\xxxx\LOGS\xxxx_log.ldf’. Diagnose and correct the operating system error, and retry the operation.

    Please Help Me

    #545 Score: 0
    Stephen West
    Moderator
    4 pts

    1. Create a new database with same name to default database location.
    2. Stop SQL server.
    3. Copy old mdf file to overwrite newly created mdf file and delete new ldf file
    4. Start SQL Server, database will be in emergency mode
    5. Detach the emergency mode database
    6. Copy original ldf file to default database location (where new LDF file as created and deleted under step 3 above.
    7. Attach the database MDF file.

    Hope it will work for you

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.