0

In Windows, I am trying to import a large SQL dump file (4.6 GB) into SQL Server 2008. Since it's a large file, I used

sqlcmd -S <SERVER-NAME\INSTANCE> -i C:\<path_to_SQL_file>.sql -o C:\<path_to_output_file_1.txt

However, the command produces the following error:

Error: Syntax error at line 11302 near command '-' in file C:\.sql

In Mac OS X, sed -n '11302p' C:\<path_to_SQL_file>.sql produces

?????$R?}D?XL?)?_K??h?l????????p?^?'?F1璨?¸??ωN?Q???흞????????+/??I?*5jE?1????f?`?nL_?~E?????^ap??Ht?2???g
                                                                                                          ?2z7$(f???*??????C?????????A?K?хl?B?#??˞K?
                                                                                                                                                     q??z?
                                                                                                                                                          ??I.?
 ^  ?ݢ?G??cu?Zc?t?'?&L?W??s???W\|x??^_??PǴb???F???m:RY?ES??-D??L?????n??'
                                                                             3???+?ecKd?vysEkz???wh~;o7?y??\??i

I tried to inspect the file by splitting it using split command but the output is garbled.

Do you think the file is wrongly encoded? How do you feel I should proceed trying to find the error?

The dump file was earlier used by another developer who didn't have any problems with it. Unfortunately, he is on extended vacation for the time being.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
snowmonkey
  • 287
  • 1
  • 5
  • 11
  • Your real issue is the file is too large to look at using standard tools. Maybe use `head` to get the first 20,000 lines and look at them in an editor? Alternatively break the file up at the "GO" statements then run them one by one. You can easily make a perl or awk script to do this. – Ben Apr 22 '15 at 08:13
  • The file was wrongly saved as an sql file. It's a binary .bak file and so restoring to a new database solved the issue. Thanks for your input. – snowmonkey Apr 27 '15 at 18:13

0 Answers0