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

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.


I have a partial answer to part 2 of your question 'Why does ogr2ogr throw the error about the geometry_columns table already being created?'

I'm performing a .SHP into MSSQLSpatial using OGR2OGR and also getting the

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.

The MSSQL database I'm loading to also has SDE on it. There is no table called geometry_columns but there is a table called sde_geometry_colums and a stored procedure name geometry_columns. My guess is that ogr2ogr is checking whether a table called geometry_columns exists and if it doesn't then create it. So it's not finding the geometry_columns table and then trying to create the geometry_columns table. Because there is an object (the stored proc) called geometry_columns an error will be thrown when ogr2ogr tries to create a table of the same name. I tested this by renaming the stored proc and re-running ogr2ogr and I no longer get the error. I'm performing all this on a test database and I don't know what the implications are for SDE by renaming this stored proc...