View Code
--返回由备份集.bak文件内包含的数据库和日志文件列表组成的结果集。
--
主要获得逻辑文件名

restore filelistonly
from disk='G:\heaninfo\MyDatabase.Bak'
go 
还原数据库时错误:The backup set holds a backup of a database other than the existing 'AAA' database.解决


/*
利用bak恢复数据库,强制还原(REPLACE)
STATS = 10 每完成10%显示一条记录
DBTest和DBTest_log是上面G:\heaninfo\MyDatabase.Bak里的逻辑文件
还原到了新建的db数据库中 
*/

USE master
RESTORE DATABASE DB 
   
FROM DISK = 'G:\heaninfo\MyDatabase.Bak'
   
WITH MOVE 'DBTest' TO 'E:\DB.mdf'
   MOVE 
'DBTest_log'  TO 'E:\DB_log.ldf',
STATS 
= 10REPLACE
GO

 

相关文章:

  • 2021-08-18
  • 2022-01-21
  • 2022-12-23
  • 2021-10-09
  • 2017-11-28
  • 2021-09-10
  • 2021-06-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2021-05-08
相关资源
相似解决方案