代码如下:
use master
RESTORE DATABASE KnowledgeData from disk =
'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
以下是报错信息:
Msg 3154, Level 16, State 4, Line 2
The backup set holds a backup of a database other than the existing 'KnowledgeData' database.
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
还需要什么设置吗?请高手指教
6 个解决方案
#1
RESTORE DATABASE [AdventureWorksNew]
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'AdventureWorks_Data' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'AdventureWorks_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'AdventureWorks_Data' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'AdventureWorks_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
#2
RESTORE DATABASE [KnowledgeData]
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'KnowledgeData' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'KnowledgeData_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'KnowledgeData' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'KnowledgeData_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
#4
谢谢,不过还是报同样的错误,另外我的sqlserver2005是装在D盘的
#5
--获得备份数据库的逻辑名
restore filelistonly from disk='g:\Test_20090917132413_D.BAK'
--用bak还原Test数据库
restore database Test from disk='G:\Test_20090917132413_D.bak'
with move 'Testf_Data' to 'G:\Sqldata\Test_Data.mdf',
move'Testf_Log' to 'L:\Test_Log.ldf'
GO
--修改生成后数据库的逻辑名(如果两数据库名称不同)
ALTER DATABASE Test
MODIFY FILE (NAME = 'Testf_data', NEWNAME = 'Test_data')
GO
ALTER DATABASE Test
MODIFY FILE (NAME = 'Testf_log', NEWNAME = 'Test_log')
#6
restore successfully!
#1
RESTORE DATABASE [AdventureWorksNew]
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'AdventureWorks_Data' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'AdventureWorks_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'AdventureWorks_Data' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'AdventureWorks_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
#2
RESTORE DATABASE [KnowledgeData]
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'KnowledgeData' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'KnowledgeData_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
FROM DISK = N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\KnowledgeData_20100606.bak'
WITH FILE = 1,
MOVE N'KnowledgeData' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData.mdf',
MOVE N'KnowledgeData_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\KnowledgeData_Log.ldf',
NOUNLOAD, STATS = 10
#3
#4
谢谢,不过还是报同样的错误,另外我的sqlserver2005是装在D盘的
#5
--获得备份数据库的逻辑名
restore filelistonly from disk='g:\Test_20090917132413_D.BAK'
--用bak还原Test数据库
restore database Test from disk='G:\Test_20090917132413_D.bak'
with move 'Testf_Data' to 'G:\Sqldata\Test_Data.mdf',
move'Testf_Log' to 'L:\Test_Log.ldf'
GO
--修改生成后数据库的逻辑名(如果两数据库名称不同)
ALTER DATABASE Test
MODIFY FILE (NAME = 'Testf_data', NEWNAME = 'Test_data')
GO
ALTER DATABASE Test
MODIFY FILE (NAME = 'Testf_log', NEWNAME = 'Test_log')
#6
restore successfully!