Error when restoring filegroup:
"Msg 62309, Level 19, State 1, Line 1
SQL Server has returned a failure message to LiteSpeed 2005 which has prevented the operation from succeeding.
The following message is not a LiteSpeed 2005 message. Please refer to SQL Server books online or Microsoft technical support for a solution:
RESTORE DATABASE is terminating abnormally.
The backup set holds a backup of a database other than the existing <dbname> database."
Scriping error
Even if only restoring one filegroup, all files in the backup set must be identified.
Examples:
Wrong Script:
exec master.dbo.xp_restore_database @database = 'PartialTest_R'
, @filename = 'D:\LiteSpeedTest\Backup 2005\PaartialTest_Pri.bak'
, @filenumber = 1
, @filegroup='PRIMARY'
, @with = 'RECOVERY'
, @with = 'NOUNLOAD'
, @with = 'STATS = 10'
, @with = 'REPLACE'
, @with = 'MOVE N''SPri1_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data.mdf'''
, @with = 'MOVE N''SPri2_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data1.ndf'''
Correct Script:
exec master.dbo.xp_restore_database @database = 'PartialTest_R'
, @filename = 'D:\LiteSpeedTest\Backup 2005\PaartialTest_Pri.bak'
, @filenumber = 1
, @filegroup='PRIMARY'
, @with = 'RECOVERY'
, @with = 'NOUNLOAD'
, @with = 'STATS = 10'
, @with = 'REPLACE'
, @with = 'MOVE N''Sales_log'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Log.ldf'''
, @with = 'MOVE N''SPri1_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data.mdf'''
, @with = 'MOVE N''SPri2_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data1.ndf'''
, @with = 'MOVE N''SGrp1Fi1_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data2.ndf'''
, @with = 'MOVE N''SGrp1Fi2_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data3.ndf'''
, @with = 'MOVE N''SGrp2Fi1_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data4.ndf'''
, @with = 'MOVE N''SGrp2Fi2_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data5.ndf'''
The following is a runnable script. However, since the SGrp1Fi1_dat, SGrp1Fi2_dat, SGrp2Fi1_dat', SGrp2Fi2_dat' are not indicated, it will restore to the same location as the location of the backup set.
exec master.dbo.xp_restore_database @database = 'PartialTest_R'
, @filename = 'D:\LiteSpeedTest\Backup 2005\PaartialTest_Pri.bak'
, @filenumber = 1
, @filegroup='PRIMARY'
, @with = 'RECOVERY'
, @with = 'NOUNLOAD'
, @with = 'STATS = 10'
, @with = 'REPLACE'
, @with = 'MOVE N''Sales_log'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Log.ldf'''
, @with = 'MOVE N''SPri1_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data.mdf'''
, @with = 'MOVE N''SPri2_dat'' TO N''C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\PartialTest_R_Data1.ndf'''
All versions of LiteSpeed
SQL Server 2000 and SQL Server 2005