[GIS] ogr2ogr bringing up “memory allocation error”

ogr2ogrosgeo4wsql server

I've got a shapefile which contains, at the moment, roughly 1500 polygons. The polygons all display fine using whatever GIS I throw it in (ArcGIS, QGIS).

However, I'm trying to use ogr2ogr to convert it to a table on SQL Server and it gives the following error:

ERROR 1: INSERT command for new feature failed. [Microsoft][SQL Server
Native Client 11.0]Memory allocation failure ERROR 1: Unable to write
feature 8 from layer PARCEL_MP. ERROR 1: Terminating translation
prematurely after failed translation of layer PARCEL_MP (use
-skipfailures to skip errors)

Of course, I can use -skipfailures but when I do, it manages to export roughly 120 of the 1500 records (it differs each time – sometimes it's 115, sometimes 120, a bit more or less).

Obviously what I'm shooting for is 100%. The server is SQL Server 2014.

My code (running this in OSGeo4W) is:

ogr2ogr -overwrite -f MSSQLSpatial "MSSQL:server=MY_SERVER;database=MY_DATABASE;trusted_connection=yes" "PARCEL_MP.shp"

EDIT – also, the first feature that throws an error changes each time. The shapes aren't complicated and are quite small, with a small number of vertices.

Also, just tried using ogr2ogr to convert it to another shapefile which has worked fine. Think it must be in my server. Code I used was:

ogr2ogr -overwrite -f "ESRI Shapefile" "PARCEL_MP_2.shp" "PARCEL_MP.shp" -skipfailures

Best Answer

I had similar problem, I used Chirs's solution and worked for me -

    ogr2ogr -f MSSQLSpatial -overwrite  -lco UPLOAD_GEOM_FORMAT=wkt "MSSQL:server=XXXXXXX;database=XXXXXX;trusted_connection=yes" -nln "XXXXX" "XXXX.Shp"

I just used "-lco UPLOAD_GEOM_FORMAT=wkt"

Hope this helps !