Link to home
Create AccountLog in
Avatar of Gig-A-Dee
Gig-A-DeeFlag for United States of America

asked on

Restoring a SQL2008 DB on a new machine ERROR..........

Copying a live DB from one SQL2008 server to another: We've done this in the past but have slept since then! Thanks!

RESTORE DATABASE training
FROM DISK = 'H:\training.bak'
WITH REPLACE

Error:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\training_Data.MDF" failed with the operating system error 3(The system cannot find the path specified.).
Msg 3156, Level 16, State 3, Line 1
File 'training_Data' cannot be restored to 'D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\training_Data.MDF'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

It sounds like the install path for SQL Server is different on the new server than that of the backed up server.  Try using SQL Management Studio (SSMS) to initiate the attach and ensure to change the path of the MDF|LDF file to the correct one you want for the new server.
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Gig-A-Dee

ASKER

RESTORE DATABASE training
FROM DISK = 'H:\training.bak'

WITH REPLACE
      MOVE 'training_Data' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training.MDF'
      MOVE 'training_Log' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training_Log.LDF'

Errors:

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'MOVE'.

Thanks!
You need to double check the solution provided.  Note the two missing comas in your Restore statement (no points please)
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I ran Ashilo's command and here are the results:

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'training' database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.


I'm not changing the name of the DB?

Thanks!
if you wish to replace the existing database then run this command else run the previous

RESTORE DATABASE training
FROM DISK = 'H:\training.bak'
WITH REPLACE , MOVE 'training_Data' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training.MDF'
      , MOVE 'training_Log' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training_Log.LDF'

BTW if you want to restore the database besides the existing database just change the name in the recovery script to the desired name
>>if you wish to replace the existing database then run this command else run the previous<<
Which is precisely what mwvisa1 posted yesterday.
>>Which is precisely what mwvisa1 posted yesterday.

not exactly since my syntax actually works and dosent return syntax errors.

With respect.
>>not exactly since my syntax actually works and dosent return syntax errors.<<
How do you know, did you try it?  I suspect you are referring to the author's syntax and not to mwvisa1?

What difference do you see between you solution and mwvisa1's?
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ohh you mean that
well i gave the complete syntax.

With respect
This worked perfectly.

RESTORE DATABASE training
FROM DISK = 'H:\training.bak'
WITH MOVE 'training_Data' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training.MDF'
      , MOVE 'training_Log' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training_Log.LDF'

Would either of the above posts work?

But I will make it easy for you:
mwvisa1:
WITH REPLACE,
      MOVE 'training_Data' TO '{your file path}\training_Data.MDF',
      MOVE 'training_Log' TO '{your file path}\training_Log.LDF'
ashilo:
WITH REPLACE , MOVE 'training_Data' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training.MDF'
      , MOVE 'training_Log' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training_Log.LDF'

Now let's break it down one be one to make it simple for you:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

      

mwvisa1: WITH REPLACE,
ashilo:     WITH REPLACE ,

mwvisa1: MOVE 'training_Data' TO '{your file path}\training_Data.MDF',
ashilo:     MOVE 'training_Data' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training.MDF',

mwvisa1: MOVE 'training_Log' TO '{your file path}\training_Log.LDF'
ashilo:     MOVE 'training_Log' TO 'H:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\training_Log.LDF'

Can you see the difference?
all an all i guess Gig-A-Dee got his solution :-)
Gig-A-Dee:

When I posted my suggestion, you had not yet posted what your proper file path should be; therefore, I had to give you in general terms which will work for any server you are restoring to by you filling in the proper path.  If that was confusing to you, then Anthony's reminder for you to check my syntax again to see that you had copied it but forgot some commas should have helped.

I am glad you eventually figured it out.

Anyway, glad we could help.

Best regards and happy coding,

Kevin
Ya'll figured it out, not me! Many thanks to all! As always!

Great info!