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
Teoman SahinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
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.
Anoo S PillaiCommented:
SQL is confused with prefixed spaces ;-)

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

Remove the starting space from logical file names..

Anoo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.