• Blog posts



    I am running the following OGR2OGR command line to import a SHP file into my SQL Server DB:

    ogr2ogr -f "MSSQLSpatial" "MSSQL:server=PCNAME;database=DATABASENAME;trusted_connection=yes;driver=SQL Server" "D:\Temp\GISFILENAME.shp" -overwrite -SkipFailures -nln "SQLTABLENAME" -lco PRECISION=NO -progress

    However, each time I try and run the import I receive the following error message:

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

    After I receive this error message, sometimes a new Table is created in my SQL Server DB with just its schema and no records, sometimes a few of the records are imported and on other occasions I actually get duplicated records imported. How can I resolve this issue?



    This issue is linked to the version of GDAL being used in your OSGeo Command Shell. The version that your machine uses can be updated based on the version of QGIS that you have installed on that PC.

    For example if  you have installed QGIS 2.18 the GDAL version that you will be using is 2.1.3, and using this version you will receive the error messages above.

    However, if you have QGIS 2.12 installed then the OSGeo Command Shell will use GDAL 1.11.3



    Running the same Ogr2Ogr command line will then successfully import your SHP file into your SQL Database.



Please sign in to leave a comment.