1. 程式人生 > >Restore database backup from a different database name

Restore database backup from a different database name

situation:  DB1, DB2( not exists)

1. create backup of DB1, db1.bak

2. restore to DB2 with db1.bak

    1) list the logic name of backup

     RESTORE FILELISTONLY FROM DISK='D:\db1.bak'

    2) resotre

      RESTORE DATABASE DB2 FROM DISK='D:\db1.bak'
      WITH
       MOVE 'LogicName4DB1MDF' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\DB2.mdf',
       MOVE 'LogicName4DB1LDF' TO 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data\DB2_log.ldf'