Search code examples
sql-serverdatatableodbcogr2ogr

ODBC string connect to specific table


I'm connecting to a SQL Server spatial database by using ogr2ogr with the MSSQL driver.

C:\>ogr2ogr -f "GeoJSON" C:\Users\usr_m\Documents\shape_odbc.geojson "MSSQL:Driver=SQL Server;server=hksql;database=ql51pd;trusted_Connection=yes;"

as specified here and here

But I'd like to connect to download a certain table, any suggestions how I do that?

Maybe I need to fetch it in python or make another workaround.


Solution

  • As suggested on a side-note here. The string has to look like this:

    C:\>ogr2ogr -f "GeoJSON" C:\Users\usr_m\Documents\shape_odbc.geojson "MSSQL:Driver=SQL Server;server=hksql;database=ql51pd;trusted_Connection=yes;" **<table>**