Opened 7 years ago

Closed 7 years ago

#5498 closed defect (fixed)

OGR2OGR fails to recognise geometry column when querying MSSQL data source

Reported by: berwyn Owned by: tamas
Priority: normal Milestone:
Component: default Version:
Severity: normal Keywords: OGR MSSQL


The following ogr2ogr command works with: "GDAL 1.10.1, release 2013/08/26"

But fails with: "GDAL 1.12dev, released 2014/04/16"

the following message is generated:

ERROR 6: Can't create fields of type Binary on shapefile layers.

And there is no geometry assigned to the features in the shape file

ogr2ogr -a_srs EPSG:4326 -overwrite c:\temp  
    -sql "SELECT Id, Name, GEOMETRY::STGeomFromWKB(LongLat_Loc.STAsBinary(),4326) WkbGeom 
     FROM dbo.MyTable WHERE  Id = 2 and Id = 3 ;"
     -nln TestLocations

gdal/ogr was installed from binaries downloaded from

tested it with other output formats, KML ect with similar result, no assigned geometry to the features

Change History (6)

comment:1 Changed 7 years ago by Even Rouault

Perhaps you should update again your trunk (and do a full rebuild) since there has been a recent fix in MSSQL driver.

comment:2 Changed 7 years ago by berwyn

I haven't done a rebuild myself, I've been just been grabbing the recent builds (MSVC2010, Win64 )that Tamas has on gisinternals.

Latest revision: changeset 27424

All versions of 1.11 seam to be acting up.

Is there a method/need to explicitly state the geometry column for features? I tried -geomfield , with no luck

The WKB is being returned but it seams to be interpreted as a regular varbinary or binary column

comment:3 Changed 7 years ago by Even Rouault

Owner: changed from warmerdam to tamas

It is probably an issue with the MSSQL driver in trunk. No option should be needed. Passing ticket over Tamas

comment:4 Changed 7 years ago by tamas

Fixed in trunk (r27756)

comment:5 Changed 7 years ago by tamas

Fixed in branch 1.11 (r27760)

comment:6 Changed 7 years ago by tamas

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.