MSG 3154 The backup set holds a backup of a database other than the existing database.

  • GilaMonster (7/14/2014)


    sirvikasrana (7/14/2014)


    GilaMonster (7/14/2014)


    sirvikasrana (7/14/2014)


    Grant Fritchey (7/14/2014)


    Then you need to use WITH MOVE.

    Already doing it, please go through my post carefully

    Regards

    You're specifying logical file names that don't exist. According to the error message, the logical file names are SomeDB and SomeDB_Log, but your MOVE clause references SomeDBTest and SomeDBTest_Log

    You also need to restore WITH RECOVERY if you want the DB usable afterwards. Unless you're restoring log backups after, there's no reason to restore WITH NORECOVERY

    Without the variables, this is, afaict, the statement you need to run

    RESTORE DATABASE SomeDBTest FROM DISK = 'E:\MSSQLBackup\SomeDB.bak'

    WITH RECOVERY, REPLACE,

    MOVE 'SomeDB' TO 'E:\MSSQLBackup\SomeDBTest.mdf',

    MOVE 'SomeDB_Log' TO 'E:\MSSQLBackup\SomeDBTest_log.ldf'

    Please check my code above I've specified the same file names which you have added in your code..

    No they're not. You specified Test in the logical names, names which according to the errors you posted don't exist. If you're obsfucating the code, please don't, it makes things way harder to figure out.

    sirvikasrana (7/14/2014)


    RESTORE DATABASE SomeDBTest FROM DISK = @PathFile

    WITH NORECOVERY,

    MOVE 'SomeDBTest' TO @PathDB,

    MOVE 'SomeDBTest_Log' TO @PathLog

    I have done this a number of time, the code I posted is what I would use. If it's not working, post the exact error messages (no obsfucation)

    My bad, I overran your commands.. its working now!

    thanks

  • sirvikasrana (7/14/2014)


    Here is my Code:

    RESTORE DATABASE SomeDBTest FROM DISK = 'E:\MSSQLBackup\SomeDB.bak'

    WITH RECOVERY, REPLACE,

    MOVE 'SomeDBTest' TO 'E:\MSSQLBackup\SomeDBTest.mdf',

    MOVE 'SomeDBTest_Log' TO 'E:\MSSQLBackup\SomeDBTest_log.ldf'

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

    Msg 3234, Level 16, State 2, Line 2

    Logical file 'SomeDBTest' is not part of database 'SomeDBTest'. Use RESTORE FILELISTONLY to list the logical file names.

    Msg 3013, Level 16, State 1, Line 2

    RESTORE DATABASE is terminating abnormally.

    That failed because the logical file names were wrong. The logical file names come from the backup (from the DB which was the source of the backup), they're not defined by what you're restoring to.

    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 2 posts - 16 through 16 (of 16 total)

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