Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What SQL argument have I got wrong?

Background: I have both SQL2008 and SQL2012 installed on my machine. This has resulted in only having the studio management for 2012 running, and any amount of trying wont let me add the studio for 2008.

Problem: Now I have backup that for verification reasons need to be restored on the 2008 instance without the 2012 management studio to avoid contamination, so I am trying to run the restore directly from the command prompt. I have let the 2012 studio make the actual command for me, and am now trying to put that into the prompt, but it won't run; and no amount of reading makes me see the invalid argument. I realize I am probably missing something elemental, but please have a look at it anyway.

The command that I am trying to run is:

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>SqlCmd -E -S SQL2008 "RESTORE DATABASE Basename FROM  DISK = N'D:\Folder\Backup.BAK' WITH  FILE = 1,  MOVE N'Base_Data' TO N'C:\Folder\Base.mdf',  MOVE N'Base_1_Data' TO N'C:\Folder\Base_1.ndf',  MOVE N'Base_2_Data' TO N'C:\Folder\Base_2.ndf',  MOVE N'Base_Log' TO N'C:\Folder\Base_3.LDF',  NOUNLOAD,  STATS = 5"

And the response is a quick: Unexpected argument. Enter '-?' for help.

I don't see how -E or -S could be wrong, and the server is correct 2008 instance. I have tried it without the MOVEs to see if there could be something there, but it gave the same result.

So could someone please swing a 2 by 4 my way letting me know what I am doing wrong? Thank you

like image 716
Svend Avatar asked Oct 21 '22 21:10

Svend


1 Answers

Maybe like this?

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>SqlCmd -E -S SQL2008 -Q "RESTORE DATABASE Basename FROM  DISK = N'D:\Folder\Backup.BAK' WITH  FILE = 1,  MOVE N'Base_Data' TO N'C:\Folder\Base.mdf',  MOVE N'Base_1_Data' TO N'C:\Folder\Base_1.ndf',  MOVE N'Base_2_Data' TO N'C:\Folder\Base_2.ndf',  MOVE N'Base_Log' TO N'C:\Folder\Base_3.LDF',  NOUNLOAD,  STATS = 5"
like image 70
RBarryYoung Avatar answered Nov 15 '22 05:11

RBarryYoung