Assume you have database called Sales_DB in your SQL Server. You planning to migrate this databases to another SQL Server and you want to place the database files (.mdf and .ldf) in different locations to those recorded in the backup from the original server.
Below script will help you to restore Sales_DB database to different location. Note that the MOVE option requires the specification of the logical file name, rather than the original physical file path.
1 2 3 4 5 6 7 |
RESTORE DATABASE Sales_DB FROM DISK = 'F:\Backups\ Sales_DB.bak' WITH MOVE ' Sales_DB _Data' TO 'S:\ Sales_DB.mdf', MOVE ' Sales_DB _Log' TO 'L:\ Sales_DB.ldf'; |
Leave a Comment