Restore SQL .bak file to a different server

To restore a sql.bak file you first need to find the name of the database files:

RESTORE FILELISTONLY
FROM DISK = 'full path to your .bak file'

This will show you the names needed for extracting the original files to your sql server directory:

RESTORE DATABASE MyNewDBname
    FROM DISK = 'full path to your .bak file'
    WITH 
      MOVE 'LogicalFilename_Data' TO 'D:\somepath\...\MyDB.mdf',
      MOVE 'LogicalFilename_Log' TO 'D:\somepath\...\MyDB.ldf';
GO

 

Leave a Reply

Your email address will not be published. Required fields are marked *