Link to home
Start Free TrialLog in
Avatar of Teoman Sahin
Teoman Sahin

asked on

Logical name is not part of database--ERror...

I would like to daily task which backups the database Roll_1C then restore from last backup Roll_1C.bak to database Roll_2C on the same server in sql server 2008 so I have a script for this task so first step to backup this Roll_1C database is working properly but the second step to restore other database Roll_2C is not working ..what should we do?

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

here is the script

USE master
GO

RESTORE FILELISTONLY
FROM DISK = 'E:\Backup\Roll_1C.bak'

Logical name;                                            PhysicalName;

Roll_1C_Test                                           e:\ProgramFiles\...\Data\Roll_1C_Test.mdf

Roll_1C_Test_log                                    e:\ProgramFiles\...\Data\Roll_1C_Test_1.ldf


RESTORE DATABASE [Roll_2C] FROM DISK = 'E:\Backup\Roll_1C.bak'
WITH REPLACE,NORECOVERY,
MOVE ' Roll_1C_Test' TO 'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\Roll_2C.mdf ',
MOVE ' Roll_1C_Test_log' TO 'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\Roll2C_log.LDF '
GO


database Roll2C;

logical names                                                  Physical names

Roll_1C_Test                                                 Roll_2C.mdf
Roll_1C_Test_log                                          Roll2C_log.LDF
Avatar of Lee
Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

The way I would achieve this is to first, set up the backup using Tasks -> Backup in SQL Management Studio and when it is configured, BEFORE you run it, click on the Script button at the top of the Backup dialog window and script to a new query window.

Then do the same for restoring. Once you have your basic scripts, then you can modify them. In the restore windows, click on the Script to a new query window.

Hope that helps.
ASKER CERTIFIED SOLUTION
Avatar of Anoo S Pillai
Anoo S Pillai
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial