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

Reetz, Michael (NLPV) Michael.Reetz at nlpvw.niedersachsen.de
Thu Oct 20 06:31:07 PDT 2022


Hi Bo,

thank you for the links. I’ve tried some examples from https://alastaira.wordpress.com/ogr2ogr-patterns-for-sql-server/ and others but all tests starting with MSSQL throw an error, even if I just query a simple table with only one geometry attribute. The pattern that I’ve used is from this page: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/335d3f6b-11f4-4e02-8d6d-b49cb59ed98d/using-ogr2ogr-to-reproject-within-a-sql-table?forum=sqlspatial. It is from 2012 but should still work.

One of my problems with software is that I’m not allowed to install anything. We have a central department that cares for thousands of computers with the focus on standardization and security issues. If I want to have installed something, I have to order it, than a package will be produced and tested and after weeks or months it will be provided in the software center of my computer. So I was happy to have QGIS installed that brings some GDAL features with it.

Maybe the GDAL-DEV group will tell me that I’ll have to make a complete install. Than it will take some time.

Best regards
Michael



Von: Qgis-user <qgis-user-bounces at lists.osgeo.org> Im Auftrag von Bo Victor Thomsen via Qgis-user
Gesendet: Donnerstag, 20. Oktober 2022 14:36
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.

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><mailto: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<mailto: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
[2] https://lists.osgeo.org/mailman/listinfo/gdal-dev



_______________________________________________

Qgis-user mailing list

Qgis-user at lists.osgeo.org<mailto: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/ac90b294/attachment.htm>


More information about the Qgis-user mailing list