0

I'm trying to restore a multiple disk/media back up using the below command when I use 1 or 2 disks its fine. In this case I am using 23. It fails with an error query is too long. Could not find any good solution .please help .

osql -Q \"restore database dbname from disk = 'C:\temp\y.bak0', disk = 'C:\temp\y.bak1', 
disk = 'C:\temp\y.bak10', disk = 'C:\temp\y.bak11', disk = 'C:\temp\y.bak12', disk = 'C:\temp\y.bak13', disk = 'C:\temp\y.bak14', disk = 'C:\temp\y.bak15', disk = 'C:\temp\y.bak16', disk = 'C:\temp\y.bak17', disk = 'C:\temp\y.bak18', disk = 'C:\temp\y.bak19', disk = 'C:\temp\y.bak2', disk = 'C:\temp\y.bak20', disk = 'C:\temp\y.bak21', disk = 'C:\temp\y.bak22', disk = 'C:\temp\y.bak3', disk = 'C:\temp\y.bak4', disk = 'C:\temp\y.bak5', disk = 'C:\temp\y.bak6', disk = 'C:\temp\y.bak7', disk = 'C:\temp\y.bak8', disk = 'C:\temp\y.bak9' with move '123_Data' to 'C:\temp\dummy1.mdf', move '123_log' to 'C:\temp\dummy.ldf'\" -S -E"
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Arunachalam
  • 5,417
  • 20
  • 52
  • 80
  • Can you put the query in a file and use `-i ` instead of `-Q `? – Dave Mason Jul 10 '14 at 18:58
  • Invalid usage of parameter -i ..should I use a .sql file ? – Arunachalam Jul 10 '14 at 19:42
  • Here's the [osql documentation](http://msdn.microsoft.com/en-us/library/ms162806(v=sql.105).aspx). (There's a link at the top to change to the appropriate SQL Server version.) Note that the command line parameters are case-sensitive. – Dave Mason Jul 10 '14 at 19:55
  • The problem its not identifying the fiole correctly ..I used // to distinguish it but still it considers for e.g. if the path is "c://temp//temp.txt" it assumes as "c:temp temp.txt" .I even used a variable name – Arunachalam Jul 10 '14 at 20:10
  • osql is not finding the file with the `-i` parameter? SQL Server can't find the backup file(s) referenced in your script? Or something else? – Dave Mason Jul 10 '14 at 20:18
  • "osql -i out.txt" - msg: Cannot open input file - out.txt – Arunachalam Jul 10 '14 at 20:28
  • You may need a fully qualified path for the file name. For example: `osql -i "C:\Some Folder\Your DB Restore Script.sql"` – Dave Mason Jul 10 '14 at 20:33
  • I did use full path but it omits all // and says can not find file .I think I m doing something very silly – Arunachalam Jul 10 '14 at 20:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/57120/discussion-between-dmason-and-arunachalam). – Dave Mason Jul 10 '14 at 20:46

0 Answers0