Search code examples
sql-serverssmssqlcmdssms-2012

SQLCMD to import large sql file gives "Invalid object name" error


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.


Solution

  • 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.