[Qgis-user] ogr2ogr doesn't connect to MS SQL Server

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Thu Oct 20 05:36:07 PDT 2022


Hi Michael -

1) You can get a complete windows GDAL/OGR setup from 
https://www.gisinternals.com/

2) Have you read this article : 
https://alastaira.wordpress.com/ogr2ogr-patterns-for-sql-server/

Especially the chapter about exporting data from SQL-Server.

An example:

|ogr2ogr|
|-f ||"KML"|
|"C:\temp\precincts.kml"|
|"MSSQL:server=localhost\denali;database=tempdb;trusted_connection=yes;"|
|-sql ||"SELECT prcnts_id, geog4326.STAsBinary() FROM 
precincts_reprojected"|
|-overwrite|

I have a hunch, that your problem stems from the use of both a geometry 
and a geography column in the same table. The -sql "select a,b..." might 
eliminate this problem by only including one of the geometry columns in 
the field lidst.



Med venlig hilsen / Best regards

Bo Victor Thomsen

Den 20-10-2022 kl. 13:59 skrev Reetz, Michael (NLPV) via Qgis-user:
>
> Hi Andrea and Ian,
>
> yes, I’ve read the documentation and a lot of other tips. I’ve signed 
> in to the gdal-dev mailing list and will post my problem there as soon 
> as the registration is done. I will post the result here if there is a 
> solution.
>
> Thanks and best regards
>
> Michael
>
> *Von:* Qgis-user <qgis-user-bounces at lists.osgeo.org> *Im Auftrag von 
> *Andrea Giudiceandrea via Qgis-user
> *Gesendet:* Donnerstag, 20. Oktober 2022 11:14
> *An:* qgis-user at lists.osgeo.org
> *Betreff:* Re: [Qgis-user] ogr2ogr doesn't connect to MS SQL Server
>
> ACHTUNG!!Diese E-Mail erreicht Sie von einem Absender außerhalb der 
> niedersächsischen Landesverwaltungs-Infrastruktur mit 
> TLS-Verschlüsselung. Bitte klicken Sie auf keine Links oder öffnen Sie 
> keine E-Mail-Anhänge, falls Sie den Absender nicht kennen und nicht 
> wissen, ob der Inhalt sicher ist.
>
>     *Reetz, Michael (NLPV)*
>     /Thu Oct 20 01:39:42 PDT 2022/
>
>     ------------------------------------------------------------------------
>
>     So, it looks as if ogr2ogr is not really helpful for me and I have
>     to look for another tool.
>
>
> Hi Michael,
> AFIAK QGIS has its own MSSQL provider since 2012, while ogr2ogr relies 
> on the GDAL/OGR library to connect to an MSSQL server: have you 
> already read the documentation at [1]?
>
> I suggest you to also ask the gdal-dev mailing list [2] for help.
>
> Best regards.
>
> Andrea Giudiceandrea
>
> [1] https://gdal.org/drivers/vector/mssqlspatial.html 
> <https://gdal.org/drivers/vector/mssqlspatial.html>
> [2] https://lists.osgeo.org/mailman/listinfo/gdal-dev 
> <https://lists.osgeo.org/mailman/listinfo/gdal-dev>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20221020/fc6da7ad/attachment-0001.htm>


More information about the Qgis-user mailing list