用SQL语句恢复备份到新数据库

RESTORE DATABASE YourDB2  /* YourDB2 新数据库*/
from disk='D:/YourDB1_backup_200807141721.bak'  /* YouerDB1的备份文件*/
with

move 'YourDB1_Data'  to 'D:/Invoice/db/YourDB1_200807141721_Data.mdf',
move 'YourDB1_Log'  to 'D:/Invoice/db/YourDB1_200807141721_Log.ldf'Replace



<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>

REPLACE

Specifies that SQL Server should create the specified database and its related files even if another database already exists with the same name. In such a case, the existing database is deleted. When the REPLACE option is not specified, a safety check occurs (which prevents overwriting a different database by accident). The safety check ensures that the RESTORE DATABASE statement will not restore the database to the current server if:

  1. The database named in the RESTORE statement already exists on the current server, and
  2. The database name is different from the database name recorded in the backup set.

REPLACE also allows RESTORE to overwrite an existing file which cannot be verified as belonging to the database being restored. Normally, RESTORE will refuse to overwrite pre-existing files.

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值