Saturday, 9 December 2017

gdal - What if 'geometry_columns' already exists in MSSQL Server Database?


When trying to load a .SHP into MSSQLSpatial using OGR2OGR, I get the following error:


ERROR 1: Error initializing the metadata tables : [Microsoft][ODBC SQL Server Dr
iver][SQL Server]There is already an object named 'geometry_columns' in the data
base.

I can see the entries using this query:



SELECT *
FROM giswork.INFORMATION_SCHEMA.COLUMNS
where table_name like 'geometry%'

And the result looks like this:


enter image description here


And If I dig deeper with this query:


select * from matthew_baker.geometry_columns

I get a set of empty results:



enter image description here


My questions:



  • What should be in the geometry_columns table (if it's not there already...)

  • Why does og2ogr throw the error about the geometry_columns table already being created?


EDIT: It seems that GDAL created these tables when I tried to use the OGR2OGR command - they have not been in my database until now. My current spatial data was created using FME and is updated with FME.


I can view AND edit my MSSQLSpatial tables in QGIS 2.10 without any issues, across multiple schemas in my database.



Answer



I have stumbled on this issue lately, and if you set the MSSQLSPATIAL_USE_GEOMETRY_COLUMNS environment variable to NO, then the error message disappears. Related documentation here.



Hope it helps somebody later.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...