1

我试图通过 .bak 文件恢复数据库,同时恢复我遇到了这个错误

在此处输入图像描述

如何避免此错误并成功还原,

注意:针对这个 Dababase

1. one .mdf file Ex: <DBNAME>_Primary01.mdf (Logical Name: FI_Primary)
2. one .ldf file EX: <DBNAME>_Log01.ldf (Logical Name: FI_Log)
3. six .ndf file Ex: <DBNAME>_Data01.ndf (Logical Name: FI_Data)
                 Ex: <DBNAME>_Data_201.ndf(Logical Name: FI_Data_2)
                 Ex: <DBNAME>_Index01.ndf(Logical Name: FI_Index)
                 Ex: <DBNAME>_Index_201.ndf(Logical Name: FI_Index_2)
                 Ex: <DBNAME>_Large01.ndf(Logical Name: FI_Large)
                 Ex: <DBNAME>_Large_Index01.ndf(Logical Name: FI_Large_Index)

RESTORE DATABASE [MESDB] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Backup\MESDB.bak' 
WITH  FILE = 1,  MOVE N'FI_Primary' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.mdf',  
MOVE N'FI_Data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf',  
MOVE N'FI_Index' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf',  
MOVE N'FI_Data_2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf', 
 MOVE N'FI_Index_2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf',  
 MOVE N'FI_Large' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf',  
 MOVE N'FI_Large_Index' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf',  
 MOVE N'FI_Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ldf',  NOUNLOAD,  STATS = 10
GO
4

2 回答 2

2

大多数情况下,您可能已经在“C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MESDB.ndf”中有一个数据库文件,并将其附加到正在运行的数据库中。

您应该删除现有数据库,或恢复到新位置。我将您的路径重命名为一个名为 DATA2 的目录。那应该没问题。

RESTORE DATABASE [MESDB] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Backup\MESDB.bak' 
WITH  FILE = 1,  MOVE N'FI_Primary' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.mdf',  
MOVE N'FI_Data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf',  
MOVE N'FI_Index' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf',  
MOVE N'FI_Data_2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf', 
MOVE N'FI_Index_2' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf',  
MOVE N'FI_Large' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf',  
MOVE N'FI_Large_Index' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ndf',  
MOVE N'FI_Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA2\MESDB.ldf',  NOUNLOAD,  STATS = 10
GO
于 2013-05-16T14:18:06.807 回答
1

您不能在同一文件路径中有多个数据文件(显然......)。MESDB.ndf用于多个文件。给每个文件一个唯一的物理路径。

于 2013-05-16T14:28:29.677 回答