[gdal-dev] Problems with reading data into SQLServer

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Mon Jun 29 04:45:07 PDT 2020


Hi all -

I'm trying to use ogr2ogr to read shape data into a SQL Server Spatial 
database using ogr2ogr.

The problem is that I have a insert trigger (which is absolutely 
necessary) on the receiving table.

The command is like this:

*ogr2ogr.exe --config MSSQLSPATIAL_USE_BCP false -append -skipfailures 
-a_srs EPSG:25832 -nlt PROMOTE_TO_MULTI -nln gnss_data -lco 
SCHEMA=transit -lco SPATIAL_INDEX=no -lco GEOMETRY_NAME=sp_geometry -lco 
FID=mi_prinx -dialect SQLITE -sql "SELECT ID AS id, TYPENAVN AS 
typenavn, KATEGORI AS kategori, REGISTRE AS registrering, 
ST_GeometryType(geometry) AS kommentar, DATO AS oprettet, INITIALER AS 
ini, 'Punkter.shp' AS filepath, geometry as sp_geometry from ""Punkter"" 
where IsEmpty(geometry) = 0 and IsValid(geometry) = 1" -f "MSSQLSpatial" 
"MSSQL:server=localhost\SQLExpress;database=drc-spor;trusted_connection=yes;" 
"Punkter.shp"***

Activates trigger, but is slow (even if I deactivate the trigger)

*ogr2ogr.exe --config MSSQLSPATIAL_USE_BCP true -append -skipfailures 
-a_srs EPSG:25832 -nlt PROMOTE_TO_MULTI -nln gnss_data -lco 
SCHEMA=transit -lco SPATIAL_INDEX=no -lco GEOMETRY_NAME=sp_geometry -lco 
FID=mi_prinx -dialect SQLITE -sql "SELECT ID AS id, TYPENAVN AS 
typenavn, KATEGORI AS kategori, REGISTRE AS registrering, 
ST_GeometryType(geometry) AS kommentar, DATO AS oprettet, INITIALER AS 
ini, 'Punkter.shp' AS filepath, geometry as sp_geometry from ""Punkter"" 
where IsEmpty(geometry) = 0 and IsValid(geometry) = 1" -f "MSSQLSpatial" 
"MSSQL:server=localhost\SQLExpress;database=drc-spor;trusted_connection=yes;" 
"Punkter.shp"***

No error and data is correctly read and imported fast, but no trigger 
activation.
**


Is there a qualifier/config option to get a trigger executed even if you 
are using the bcp-copy method for importing data into SQLServer ?

-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200629/c3ff6099/attachment.html>


More information about the gdal-dev mailing list