4

I am trying to import a CSV files in to SQL Server 2012 using ogr2ogr. The spatial data imports without any problems, but I cannot work out why the non spatial tables fail. I can import the data using other tools but it would be convenient if I could import everything using ogr2ogr so I can script it more easily.

My VRT file looks like this...

 <OGRVRTDataSource>
 <OGRVRTLayer name="test">
 <SrcDataSource relativeToVRT="1">test.csv</SrcDataSource>
 <FID>id</FID>
 <Field name="id" src="Id" type="Integer" />
 <Field name="Test" src="Attrib" type="string" width="100" />
 </OGRVRTLayer>
 </OGRVRTDataSource>

And my command line:-

 ogr2ogr -append -f MSSQLSpatial "MSSQL:server=SQL01;database=TESTDB;trusted_connection=yes" test.vrt

The first error I get is:-

ERROR 1: Column ogr_geometry requested for geometry, but it does not exist.

After that there are errors trying to create the attribute field because the table does not exist. If I manually create the table in SQL Server with a single field named "id", then this command works (still with error messages).

asked Apr 10, 2014 at 19:47

1 Answer 1

2

The solution was to upgrade the GDAL core libraries. Lesson learned!

answered Jun 16, 2014 at 22:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.