我有备份,我希望它将其恢复为新的 数据库Wss_Content3 backfile是Wss_Content数据库的备份。
当我运行以下代码时:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content3' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content3_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我明白了:
Msg 1834,Level 16,State 1,Line 3文件 'E:\ MSSQL \ MSSQL11.SHP2013PROD \ MSSQL \ Data \ WSS_Content.mdf'不能 覆盖。数据库'WSS_Content'正在使用它。消息3156, 级别16,状态4,行3文件'WSS_Content'无法恢复 'E:\ MSSQL \ MSSQL11.SHP2013PROD \ MSSQL \ DATA \ WSS_Content.mdf'。使用WITH 移动以识别文件的有效位置。消息1834,16级, 状态1,第3行文件 'F:\ MSSQL \ MSSQL11.SHP2013PROD \ MSSQL \ Data \ WSS_Content_log.ldf'不能 被覆盖。数据库'WSS_Content'正在使用它。消息3156, 级别16,状态4,行3文件'WSS_Content_log'无法恢复 'F:\ MSSQL \ MSSQL11.SHP2013PROD \ MSSQL \ DATA \ WSS_Content_log.ldf'。使用 WITH MOVE识别文件的有效位置。 Msg 3119,等级 16,状态1,线3问题在规划期间被确定 RESTORE语句。以前的消息提供详情。消息3013,级别 16,状态1,第3行RESTORE DATABASE异常终止。
这就像恢复数据库Wss_Content,但我想在新的数据库Wss_Content3上进行恢复。
我该怎么做?
修改 随着:
USE Master;
GO
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content3_log.ldf';
我明白了:
Msg 3154, Level 16, State 4, Line 2
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
EDIT2:
USE Master;
GO
RESTORE FILELISTONLY FROM DISK = 'f:\Fill_Wss_Content.bak'
WSS_Content E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content.mdf D PRIMARY 163158360064 35184372080640 1 0 0 140B6DD4-DCA0-4FD8-BA65-59390D5FC3B5 0 0 162484191232 512 1 NULL 133075000000938400215 F50C4B9C-B575-4158-B5D6-F44B92FE0380 0 1 NULL
WSS_Content_log F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\WSS_Content_log.ldf L NULL 22918791168 2199023255552 2 0 0 C83B63C2-B68E-4101-A52B-07EFC08446D7 0 0 0 512 0 NULL 0 00000000-0000-0000-0000-000000000000 0 1 NULL
EDIT3: 我试过这个(使用Wss_Content5.mdf和Wss_Content5_log.ldf )不存在:
RESTORE DATABASE Wss_Content3 FROM DISK = 'f:\Fill_Wss_Content.bak'
WITH
MOVE 'Wss_Content' TO 'E:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5.mdf',
---------------------------------------^^^^^
MOVE 'Wss_Content_log' TO 'F:\MSSQL\MSSQL11.SHP2013PROD\MSSQL\Data\Wss_Content5_log.ldf
不幸的是我收到了这个错误:
Msg 3154, Level 16, State 4, Line 5
The backup set holds a backup of a database other than the existing 'Wss_Content3' database.
Msg 3013, Level 16, State 1, Line 5
RESTORE DATABASE is terminating abnormally.
答案 0 :(得分:1)
您需要使用以下选项:
WITH REPLACE
如果您正在使用SQL Management Studio中的向导来还原数据库而不是命令行,则需要检查相应的选项:"覆盖现有数据库(WITH REPLACE)& #34;