[gdal-dev] Error while importing shapefiles to Sql Server

Giampaolo giampaolo.rebuzzi at i-sti.net
Mon Mar 17 07:13:17 PDT 2014


Hi, I wrote this batch file to import all the shapefiles in a folder to Sql
Server:

@ECHO OFF
setlocal EnableDelayedExpansion
echo Importing...
for %%f in (*.shp) do (
set filename=%%~nf
set filenametrunc=!filename:~3!
ogr2ogr -append -update -f MSSQLSpatial
"MSSQL:server=.\SQLEXPRESS;database=ShapeFiles;trusted_connection=yes;"
"%%f" -nln !filenametrunc!

echo !filename!
)
echo Completed
PAUSE


Shapefiles are named like this:
001boundary.shp
001grid.shp
002boundary.shp
002grid.shp
...

It works fine while importing 001boundary.shp and 001grid.shp and creating
'boundary' table and 'grid' table, but, when it tries to import
002boundary.shp and 002grid.shp, it gives me this error:

ERROR 1: Layer boundary already exists, CreateLayer failed.
Use the layer creation option OVERWRITE=YES to replace it.
ERROR 1: Terminating translation prematurely after failed
translation of layer 001boundary (use -skipfailures to skip errors)

I think it's because the tables already exists, so, how can I make it append
the new values to existing tables?

Thank you,
Giampaolo




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/gdal-dev-Error-while-importing-shapefiles-to-Sql-Server-tp5129482.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list