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:
- The database named in the RESTORE statement already exists on the current server, and
- 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.