0

I am trying to import a large .SQL file (downloaded here) (210mb) containing postcodes in a table called postcodelatlng. This is the setup: enter image description here

I tried executing the query directly in SSMS 2012 but it's complains about the lack of memory.

Further reading, pointed me use command tools using SQLCMD, where I tried:

C:\Windows\system32>sqlcmd -S (LocalDB)\v11.0 -i D:\Ben\Desktop\ukpostcodesmssql_1.sql

But this throws me this error:

Msg 208, Level 16, State 1, Server BEN-PC\LOCALDB#850F4379, Line 1  Invalid object name 'postcodelatlng'.

Which I guess it's just not reaching that table correctly. I'm sure it's probably a rookie mistake but I haven't been able to solve it.

benscabbia
  • 17,592
  • 13
  • 51
  • 62
  • Do you have access to the Import/Export Wizard? SSIS? – Dave C Oct 13 '15 at 16:49
  • @JiggsJedi yes I have access to the Import/Export wjzard. Not sure what SSIS is but I'll get back to you on that one – benscabbia Oct 13 '15 at 16:52
  • Both can load large data files no problem. The Import/Export Wizard is your best bet if you aren't familiar with SSIS. This would be used to load the CSV (raw data), not the .SQL (command) file. – Dave C Oct 13 '15 at 16:54

2 Answers2

0

The .SQL file is plain text. Open it using a text editor (I recommend NotePad++) and then copy & paste the commands into SSMS partially and execute incrementally until you have all of the records loaded.

Morpheus
  • 1,616
  • 1
  • 21
  • 31
  • 1
    I did actually find a way to split the [SQL file directly](http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/) (rather than copy and paste). But there has to be a better way than having to manually copy&paste / import 50 smaller files.... – benscabbia Oct 13 '15 at 16:56
  • Use the `Go To` command to grab a batch of `INSERTs`. In NotePad++ you can find it under the `Search` menu – Morpheus Oct 13 '15 at 16:56
  • I would think the "better" way is loading the actual data instead of using the script, but I thought you had a reason for using the .SQL instead of the .CSV. – Morpheus Oct 13 '15 at 16:58
  • 1
    I actually downloaded the file a few months ago (with the url) and never checked to see if there was a CSV file! Thanks again for your help :) – benscabbia Oct 13 '15 at 17:38
0

Don't you need to specifcy the database name? (-d db_name). Your command only looks to specify the server and sql script file.

andyb
  • 770
  • 5
  • 11
  • I've just tried specifying the db name: `C:\Windows\system32>sqlcmd -S (LocalDB)\v11.0 -d postcodelatlng -i D:\Ben\Deskto p\ukpostcodesmssql_1.sql` which gives me this `Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user ' Ben-PC\Ben'.. Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Cannot open database "p ostcodelatlng" requested by the login. The login failed.` The PC doesn't have a password, but I'll try look at the credentials flags and see if that unblocks it – benscabbia Oct 13 '15 at 17:27