When you use a statement to restore a database, the following error is reported:
Msg 3234, Level 16, State 2, line 29th
The logical file ' lenbormealorder_base_2017 ' is not part of the database ' members_01 '. Please use RESTORE filelistonly to list the logical file names.
Msg 3013, Level 16, State 1, line 29th
RESTORE DATABASE is terminating abnormally.
Cause: This database was backed up with an SQL statement, resulting in an error, the original backup and restore SQL statements are as follows:
--BackupBACKUP DATABASElearunframework_base_2016 to DISK = 'C:\DB_BACKUP\LenborMealOrder_Base_2017.bak'--RestoreRESTORE DATABASEMembers_01 from DISK = 'C:\DB_BACKUP\LenborMealOrder_Base_2017.bak' withMOVE'lenbormealorder_base_2017' to 'C:\DB_BACKUP\Members_01.mdf', MOVE'Lenbormealorder_base_2017_log' to 'C:\DB_BACKUP\Members_01.ldf'
Solution: Find the logical file name of the data, use the following statement to find out, and then modify the name in the RESTORE statement.
--restorefromdisk='c:\DB_BACKUP\LenborMealOrder _base_2017.bak'
The modified restore statements are as follows:
--RestoreRESTORE DATABASElenbormealorder_base_2017 from DISK = 'C:\DB_BACKUP\LenborMealOrder_Base.bak' withMOVE'learunframework_base_2016' to 'C:\DB_BACKUP\LenborMealOrder_Base_2017.mdf', MOVE'Learunframework_base_2016_log' to 'C:\DB_BACKUP\LenborMealOrder_Base_2017.ldf'
Executing the above statement successfully restores the database, such as:
SQL Server logical file ' is not part of database '. Please use RESTORE filelistonly to list the logical file names.