[gdal-dev] ogr2ogr doesn't connect to MS SQL Server

Pedro Venâncio pedrongvenancio at gmail.com
Thu Oct 20 07:31:05 PDT 2022


Michael,

Check if you have gdal-mss and msodbcsql libs installed, like here:
https://github.com/PedroVenancio/export_to_sql_server/issues/2#issuecomment-1240675079

Best regards,
Pedro



Reetz, Michael (NLPV) <Michael.Reetz at nlpvw.niedersachsen.de> escreveu no
dia quinta, 20/10/2022 à(s) 15:13:

> Dear members of the GDAL-DEV group,
>
>
>
> we are using MS SQL Server 2019 as basis for Geoserver and GIS software.
> There are a lot of tables that have attributes of the types geometry and/or
> geography. I can load these tables into QGIS (3.22.8) projects without any
> problems.
>
>
>
> Now I’m asked to add an geography attribute to one table that has already
> an geometry attribute and populate it with coordinates by transforming the
> geometry values. I’ve found code how to do this with ogr2ogr here:
>
>
>
>
> https://social.msdn.microsoft.com/Forums/sqlserver/en-US/335d3f6b-11f4-4e02-8d6d-b49cb59ed98d/using-ogr2ogr-to-reproject-within-a-sql-table?forum=sqlspatial
>
>
>
>
>
> Since ogr2ogr is part of the OSGeo4W Shell installed with QGIS, I’ve tried
> to run this command there.
>
>
>
> ogr2ogr -f "MSSQLSpatial" "MSSQL:server=<my server IP>;driver=ODBC Driver
> 17 for SQL Server;database=<my database>;trusted_connection=yes;"
> "MSSQL:server=<my server IP>;driver=ODBC Driver 17 for SQL
> Server;database=<my database>;trusted_connection=yes;" -sql "SELECT <my
> attributes>, GEOM.STAsBinary(), WGS84 FROM <my table>" -s_srs "EPSG:25832"
> -t_srs "EPSG:4326" -update -lco "GEOM_TYPE=geography" -lco
> "GEOM_NAME=WGS84" -nln "<my table>"
>
>
>
> But I receive the error message:
>
>
>
> “Unable to open datasource `MSSQL:server=<my server IP>;driver=ODBC Driver
> 17 for SQL Server;database=<my database>;trusted_connection=yes;' with the
> following drivers. …”
>
>
>
> MSSQLSpatial is not listed.
>
>
>
>
>
> I’ve tried some other commands but all with MSSQL in it leads to an error.
>
>
>
> Any idea what I can do to make it run?
>
>
>
> Thanks in advance and best regards,
>
>
>
> Michael
>
>
>
>
>
> Mit freundlichen Grüßen
>
> Im Auftrag
>
>
>
> Michael Reetz
>
>
>
> *****************************************
>
> Michael Reetz
>
> Datenbanken und Anwendungsentwicklung
> Nationalpark-Verwaltung Niedersächsisches Wattenmeer
> Virchowstr. 1 | 26382 Wilhelmshaven
> Tel.: +49 (0) 4421 911 291
> e-mail: michael.reetz at nlpvw.niedersachsen.de
> <michael.reetz at nlpv-wattenmeer.niedersachsen.de>
> Web: https://www.*nationalpark-wattenmeer.de
> <http://nationalpark-wattenmeer.de>*
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20221020/54a67d01/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 6534 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20221020/54a67d01/attachment.png>


More information about the gdal-dev mailing list