The backup set holds a backup of a database other than the existing 'MyDB'

  • JBentrum

    SSC Rookie

    Points: 33

    I'm trying to restore a database from our production server to my local machine using the following script but still get the error, 'The backup set holds a backup of a database other than the existing 'MyDB' database.

    USE [master]

    RESTORE DATABASE [MyDB]

    FROM DISK = 'C:\MyDB.bak'

    WITH

    REPLACE,

    MOVE 'MyDB' TO 'C:\MyDB.mdf',

    MOVE 'MyDB_log.ldf'

    GO'

  • anthony.green

    SSC Guru

    Points: 112519

    The command is somewhat incomplete, it is missing the correct syntax near move for the log file.

    It should be something more like this

    USE [master]
    RESTORE DATABASE [MyDB]
    FROM DISK = 'C:\MyDB.bak'
    WITH
    REPLACE,
    MOVE 'MyDB' TO 'C:\MyDB.mdf',
    MOVE 'MyDB_Log' TO 'C:\MyDB_log.ldf'
    GO
  • Grant Fritchey

    SSC Guru

    Points: 396760

    It is possible though that the backup has more than one database inside of it. You can query the file to find out if there's an issue.

    ----------------------------------------------------
    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
    Theodore Roosevelt

    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

Viewing 3 posts - 1 through 3 (of 3 total)

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