0

I am running

Command '['C:\\OSGeo4W\\bin\\ogr2ogr.exe', '-progress', '-skipfailures', '-overwrite', '-lco', 'UPLOAD_GEOM_FORMAT=wkt',
 '-t_srs', 'EPSG:28354', '-f', 'MSSQLSpatial', 'MSSQL:Server=xxx;Database=xxxGIS_Test;Trusted_Connect
ion=True', 'D:\\GIS_SourceData\\xxx\\HY_WATERBODY_STATE.tab', '-nln', 'DSE_HY_WATERBODY_STATE']'

But this is appending records to the table in MSSQL instead of overwriting the whole table?

Is there some switch to just tell it to update records/insert new ones or what should I do to get -overwrite to not append?

enter image description here

The _backup view is the original that was just backed up before running the command.

UPDATED EXAMPLE enter image description here

WITH DEBUG enter image description here Is there a way in OGR to delete the table or delete the records in the table before overwrite?

  • 1
    do you get the expected result if you include the -update flag? – SaultDon Mar 15 at 1:45
  • 1
    Don't swap em, need both, and add both of these too -lco OVERWRITE=YES and -append – SaultDon Mar 15 at 2:14
  • 1
    I don't know much about mssql tables, but for postgresql ones you can just use -append with --config OGR_TRUNCATE YES – SaultDon Mar 15 at 4:14
  • 1
    if you're gonna try thE TRUNCATE config option. can replace both -overwrite and -update with just -append. also the -lco options wont have any effect because the layer already exists – SaultDon Mar 15 at 5:17
  • 1
    Because the driver has its own overwrite option gdal.org/drv_mssqlspatial.html then I guess that it is made for purpose and the -overwrite option of ogr2ogr is not needed at all. Have you tried with just -lco OVERWRITE=YES? – user30184 Mar 15 at 6:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.