SQL Server restore from backup file.
1.Check backup file
restore filelistonly from disk='C:\Microsoft SQL Server\Backup\xxx.bak'
Result:
2. Restore to new database
RESTORE DATABASE xxxNewName
FROM DISK = 'C:\Microsoft SQL Server\Backup\xxx.bak'
WITH MOVE 'OldDatabase_Data'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\xxxNewName.mdf' ,
MOVE 'OldDatabase_log'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\xxxNewName_log.ldf',
replace;
restore filelistonly from disk='C:\Microsoft SQL Server\Backup\xxx.bak'
Result:
LogicalName
PhysicalName
---------------
------------------------------------------------------------------
OldDatabase_Data
d:\Program Files\Microsoft SQL
Server\MSSQL$SQLA\data\xxx.mdf
OldDatabase_log
d:\Program Files\Microsoft SQL
Server\MSSQL$SQLA\data\xxx_log.ldf
RESTORE DATABASE xxxNewName
FROM DISK = 'C:\Microsoft SQL Server\Backup\xxx.bak'
WITH MOVE 'OldDatabase_Data'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\xxxNewName.mdf' ,
MOVE 'OldDatabase_log'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\xxxNewName_log.ldf',
replace;
评论
发表评论