Restore Database from one server to the another

  • Hello All!

    I would like you to help me with syntax to restore the database

    Here is my situation I have ServerA and ServerB. ServerA has DB called TEST and is being backed up everyday on D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\Test.Bak, now I need to restore this backup on ServerB's D-drive. Help me with the T-SQL syntax. 

  • /*

     First, copy your backup file to the new server. 

    I will assume that the folder is the same. 

    Then you can cut and paste this entire message into query analyzer.

    */

    -- execute the following to get the logical file names.

       RESTORE FILELISTONLY

        FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\Test.Bak'

    -- -- Sample Results of this query

    --

    -- -- LogicalName   PhysicalName               Type  FileGroupName  Size      MaxSize

    -- -- TEST_Data     d:\SQL_Data\TEST_Data.mdf  D     PRIMARY        10485760  35184372080640

    -- -- TEST_Log      d:\SQL_Data\TEST_Log.ldf   L     NULL           27721728  36700160

    --

    /*

    Then execute the following substituting YOUR results from the above query for logicalname, and

    whatever the location is that YOU want for the physical files.

    */

       RESTORE DATABASE TEST

        FROM DISK = 'D:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\Test.Bak'

        WITH RECOVERY,

         MOVE 'TEST_Data' TO 'f:\SQL_Data\TEST_Data.mdf',

         MOVE 'TEST_Log'  TO 'L:\SQL_Logs\TEST_Log.ldf'

    -- Steve

  • Thanks very much, it worked!

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

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