10

According to http://www.gdal.org/drv_mssqlspatial.html I should be able to add a SCHEMA to my connection string to override the default "dbo" schema:

SCHEMA: Set name of schema for new table. If this parameter is not supported the default schema "dbo" is used.

But it does not seem to have any effect and I cannot find an example of how it should be done:

call ogr2ogr -overwrite -skipfailures -f MSSQLSpatial "MSSQL:server=myserver;database=mydb;trusted_connection=yes;SCHEMA=geoserver;" "C:\temp\MapVegas860\Buildings.shp"

How to import the shapefile into a 'geoserver' schema?

1
  • 2
    By reading the document "schema" is a layer creation option. Add -lco schema=geoserver into your ogr2ogr command.
    – user30184
    Commented Mar 29, 2017 at 18:49

1 Answer 1

17

SCHEMA is a "layer creation option", specified with the -lco parameter. This should do the trick (split into multiple lines here for readability):

call ogr2ogr -overwrite -skipfailures -f MSSQLSpatial
    -lco SCHEMA=geoserver
    "MSSQL:server=myserver;database=mydb;trusted_connection=yes;"
    "C:\temp\MapVegas860\Buildings.shp"
1
  • Yes, I was not understanding the documentation. Here is the fully working configuration I was looking for: ogr2ogr -skipfailures -f MSSQLSpatial "MSSQL:server=myserver;database=mydb;trusted_connection=yes;" -lco SCHEMA=geoserver -lco fid=fid -lco geom_name=geom -lco overwrite=yes "myshapefile.shp"
    – ca0v
    Commented Mar 29, 2017 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.