sql-serverogr2ogr

SQL Server ogr2ogr batch unable to access ogr_MSSQLSpatial.dll


I have an ogr2ogr batch file that reprojects SQL data into a new SQL Server table.

It works fine when I run the bat file manually but it fails if I run the bat file via a SQL Server stored procedure. I have given the gdal folders SQL Service permissions and xp_CommandShell is also enabled. I'm using

EXECUTE xp_CMDShell 'blah'

in the T-SQL script.

For some reason the ogr_MSSQLSpatial.dll causes it to fail.

ERROR 1: Can't load requested DLL: Z:\BroadSpectrumSQLTreeExtract\ogr2ogr\gdalplugins\ogr_MSSQLSpatial.dll

If I remove this dll the script runs via SQL but it means I need to add extra commands that the dll must take care of, such as setting source coordinate system. I haven't managed to get it working 100%. The furthest I got to was producing the reprojected table but the geometry field is empty.

The DLL does contain SQL commands to the system tables. Could this be a SQL Server security issue stopping it from working?


Solution

  • I again had this problem with another ogr2ogr bat while executing with SQL. If I put the bat in the same folder as the dll's it works fine.