1
backup database Clinical_Data_Extension to disk='c:\Clinical_Data_Extension_full.bak'
restore filelistonly from disk='c:\Clinical_Data_Extension_full.bak'
restore database Clinical_Data from disk='c:\Clinical_Data_Extension_full.bak'
with move 'Clinical_Data_Extension' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data.mdf',
move 'Clinical_Data_Extension_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data.ldf',
REPLACE

错误:

Msg 3234, Level 16, State 2, Line 3
Logical file 'Clinical_Data_Extension' is not part of database 'Clinical_Data'. Use RESTORE FILELISTONLY to list the logical file names.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.

然而由于某种原因,以下相同的代码可以正常工作:

backup database Clinical_Data to disk='c:\Clinical_Data_full.bak'
restore filelistonly from disk='c:\Clinical_Data_full.bak'
restore database Clinical_Data_Extension from disk='c:\Clinical_Data_full.bak'
with move 'Clinical_Data' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data_Extension.mdf',
move 'Clinical_Data_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data_Extension.ldf',
REPLACE

基本上,我正在做的是创建数据库“Clinical_Data_Extension”并对其进行处理。完成后,我有一个用于删除“Clinical_Data”的脚本,然后我使用我首先提到的脚本使用“Clinical_Data_Extension”中的数据恢复“Clinical_Data”,基本上覆盖“Clinical_Data”。但是由于某种原因,第一个脚本给了我一个错误,而第二个脚本还没有完全相同。你认为为什么会发生这种情况?

4

1 回答 1

1

不,第二个代码不相同。后

move

它说

'Clinical_Data'

不是

'Clinical_Data_Extension'

.这是至关重要的。它是备份中数据容器的逻辑名称。

USE master
GO
RESTORE FILELISTONLY
   FROM disk='c:\Clinical_Data_Extension_full.bak'

为您提供精确的逻辑名称。逻辑名称和数据库名称不需要具有相同的约定。“Clinical_Data_Extension_full.bak”中数据容器的逻辑名称可以是“Clinical_Data”,与其他备份中一样。该错误表明您指定的逻辑名称不在“c:\Clinical_Data_Extension_full.bak”中。

日志容器也可能发生相同的混淆。

于 2013-09-11T17:33:24.150 回答