如何将数据库还原到特定文件夹?

时间:2016-01-06 06:59:27

标签: c# sql sql-server

我有

中的DB Backfile
  

D:\ Prabhagar \ Projects \ ZIP \ Priya DB \ Backups \ Sample.bak

当我恢复时,它将恢复到

  

C:\ Program Files \ Microsoft SQL   服务器\ MSSQL11.SQLEXPRESS2012 \ MSSQL \ DATA

这个目录。但我想恢复到

  

D:\ Prabhagar \ Projects \ ZIP \ Priya DB \ Backups \ TestDB \

我该怎么办? 我使用了以下查询

  

RESTORE DATABASE backup_lookup FROM DISK =   ' D:\ Prabhagar \ Projects \ ZIP \ Priya DB \ Backups \ Sample.bak。'

请帮帮我。谢谢

2 个答案:

答案 0 :(得分:0)

尝试以下命令。

RESTORE DATABASE backup_lookup FROM DISK = 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\Sample.bak' 
WITH REPLACE, 
MOVE 'backup_lookup_DATA' TO 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\TestDB\backup_lookup.mdf', 
MOVE 'backup_lookup_LOG' TO 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\TestDB\backup_lookup_1.ldf'

答案 1 :(得分:0)

你可以试试这个:

RESTORE DATABASE Sample FROM DISK = 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\Sample.bak'
WITH MOVE 'Sample_Data' TO 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\TestDB\Sample_Data.mdf',
MOVE 'Sample_Log' TO 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\TestDB\Sample_Log.ldf',
NORECOVERY
GO
RESTORE LOG Sample FROM DISK = 'D:\Prabhagar\Projects\ZIP\Priya DB\Backups\TestDB\Sample.TRN'
GO