Restoring off-site backup without changing logical file name

  • Currently I am automating a nightly restore of a database backup from off-site.

    RESTORE DATABASE @aDatabaseName FROM

    DISK = @aBackupLocation WITH FILE = 1,

    MOVE @aDatabaseName TO @aMdfLocation,

    MOVE @aLogName TO @aLdfLocation,

    NOUNLOAD, REPLACE, STATS = 10

    The first run after creating the database works correctly. However after the first run the restore has renamed the logical file name for the database.

    OttawaFabrication to FABDB

    There are multiple offsite locations with logical filenames similar or identical.

    I can do an alter after the restore (below),

    ALTER DATABASE [OttawaFabication] MODIFY FILE (NAME=N'FABDB', NEWNAME=N'OttawaFabrication)

    but was searching for a setting in [RESTORE DATABASE].

    Thanks, just looking for an elegant one step, though two steps is a workable plan B ...

    Daryl

  • I see that @aDatabaseName is used with RESTORE DATABASE and MOVE. Are the database name & logical name of the data file actually the same in the original database? I know in most cases it is, but I have come across ones where it isn't.



    Scott Duncan

    MARCUS. Why dost thou laugh? It fits not with this hour.
    TITUS. Why, I have not another tear to shed;
    --Titus Andronicus, William Shakespeare


  • The original database ( and logical) name is FTDB. I went for a more informational name for the replicated copy.

    thanks

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

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