简体   繁体   中英

Query for restoring a .bak file to a new Database?

I am using this query to restore my back up file to a new database.

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

RESTORE DATABASE TestDB2 
FROM disk = 'D:\abc.bak'
WITH
MOVE 'cse' TO 'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL \DATA\TestDB2.mdf',
MOVE 'cse_log' TO 'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestDB2_log.ldf'
GO

But it is throwing an error:

Msg 3132, Level 16, State 1, Line 1
The media set has 2 media families but only 1 are provided. All members must be provided.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

I am new to SQL Server 2008. Please help.

RESTORE DATABASE TestDB2 
FROM DISK = 'D:\abc.bak'
WITH FILE = 1,  
MOVE 'CSE' TO N'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL \DATA\TestDB2.mdf',  
MOVE N'(your DB name)_LOG' TO N'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TestDB2_log.ldf',  
NOUNLOAD,  
REPLACE,  
STATS = 10
GO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM