RESTORE DATABASE TargetDB FROM DISK = 'D:DataBaseDB.bak' with replace, MOVE 'DB' TO 'D:DataBaseTargetDB.mdf', MOVE 'DB_log' TO 'D:DataBaseTargetDB_log.ldf'
以上这段代码可以用来使用备份文件还原数据库,可以解决“备份集中的数据库备份与现有的数据库不同”的问题。
亲测,方便快捷。
该文章还发布在起飞网:http://www.qeefee.com/sqlserver-restore-database-code