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

Jürgen E. Fischer jef at norbit.de
Thu Oct 20 07:29:02 PDT 2022


Hi Michael,

On Wed, 19. Oct 2022 at 10:49:35 +0000, Reetz, Michael (NLPV) via Qgis-user wrote:
> 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.

QGIS has a native MSSQL provider and doesn't need GDAL/OGR with MSSQL support.
But you can install gdal-mss (from OSGeo4W setup; also included in the
standalone) to add that.

> 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 would have thought that would be a two liner in SQL.  But I wasn't awar that
MSSQL doesn't have st_transform - if that's still the case.  But you can also
do the second step in QGIS.

Suppose you have a table foo with a geometry column, via browser add a
geography column using execute SQL:

ALTER TABLE foo ADD geog geography

Add the layer with the original geometry column and execute in field calculator to the
geog field:

geom_to_wkt(transform($geometry, 'EPSG:25832', 'EPSG:4326'))


Jürgen

-- 
Jürgen E. Fischer           norBIT GmbH             Tel. +49-4931-918175-31
Dipl.-Inf. (FH)             Rheinstraße 13          Fax. +49-4931-918175-50
Software Engineer           D-26506 Norden            https://www.norbit.de
QGIS release manager (PSC)  Germany                 IRC: jef on Libera|OFTC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20221020/80283dae/attachment.sig>


More information about the Qgis-user mailing list