I have been using ogr2ogr to write point shapefiles to a SQL Server Database of mine.

I used it 2 weeks ago and it worked fine, but, today when I tried to run it, I get the following error:

ERROR1: INSERT command for new feature failed. [Microsoft][SQL Server Native Client 11.0]Memory allocation failure`

ERROR1: Unable to write feature 0 from layer points.`

I used -skipfailures to see what output is produced, and only some of the results are written to a sql table, in this case I have 8 points, and only 5 have been written to a sql table... what could be causing this to happen? Here is the ogr2ogr command I am using, ogr2ogr -f MSSQLSpatial "MSSQL:server=servername\SQL2012;database=db;UID=username;PWD=password" C:\Pathtoshape\points.shp

I am wondering if I have fatally altered my code by mistake, or is there some other reason and now it is causing this error...

I am working on a solution, and hopefully I or someone else can find the solution, this question hasnt worked for me: ESRI Shapefile not loading into SQL Server

  • The errors might be pointing to a issue on the sql server end. Does it have enough memory? – Nathan W Jul 5 '16 at 3:18
  • @NathanW I thought that may be an issue, but there are 70 odd Gigabytes free – user32496 Jul 5 '16 at 6:08

I cannot confirm the cause, but this error occurs for me when using gdal 2.1.1. Downgrading gdal to 2.0.1 fixes this issue (haven't tried any versions in between, those two I had available).


This happened to me after upgrading QGIS from 2.12 (Lyon) to 2.16 (Nodebo). I rolled back to QGIS Lyon 2.12.1 and it worked again.

  • 2
    The question makes no mention of using QGIS so how does this answer apply to it? – PolyGeo Aug 31 '16 at 3:07
  • 2
    I meant I've been using OGR2OGR to upload shapefiles to SQL Server (nearly identical syntax as op's), and it worked fine until I decided to upgrade QGIS, then got the same exact error, i.e. ERROR1:INSERT command... ogr2ogr.exe is in the \bin folder of QGIS. Rolling back QGIS to previous version fixed the error. ergo... – Dan Aug 31 '16 at 5:55
  • As a new user be sure to take the 2-minute Tour to learn about the site and its protocols. There is an edit button beneath your answer that you can use to make your answer clearer. – PolyGeo Aug 31 '16 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy