Restoring db1 to db2 with FILELISTONLY is failing?

  • OK, so I'm using the example script from BOL to do a simple BACKUP and RESTORE, instead of replication (please, do not go there...)

    The BACKUP bit works fine, but when I do the RESTORE:

    restore FILELISTONLY

    from disk = 'c:\DB1 copy.bak'

    RESTORE DATABASE DB2

    FROM DISK = 'c:\DB1 copy.bak'

    WITH MOVE 'DB1' TO 'F:\SQL Data Files\DB2.mdf',

    MOVE 'DB1_log' TO 'L:\SQL Logs\DB2_Log.LDF'

    GO

    it fails.

    I ran it through QA, and can see the FILELISTONLY stage work - 2 rows affected reported - but come the DATABASE, it fails.

    Am I missing something?

  • The filelistonly function is so that you can see the contents of the backup file and then use that to build your restore statement. The restore syntax would be restore database DBName from disk = ...

    Hope this helps.

    David

    @SQLTentmaker

    “He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot

  • DavidB (3/10/2009)


    The filelistonly function is so that you can see the contents of the backup file and then use that to build your restore statement. The restore syntax would be restore database DBName from disk = ...

    Hope this helps.

    Ah - I get the point. You have to MOVE the FILE names, not the database names.

    A badly scripted example, that one....

  • Moe the logical names, not the physical ones.

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

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