[gdal-dev] Import Shapefile into SQL Server on Ubuntu

Mateusz Loskot mateusz at loskot.net
Mon Oct 22 08:31:07 PDT 2018


On Mon, 22 Oct 2018 at 17:25, Peter Marlow <Peter.Marlow at scisys.co.uk> wrote:
>
> I’m trying to import a Shapefile into an SQL Server database using ogr2ogr on Ubuntu. The command I’m running looks like:
>
> ogr2ogr -f MSSQLSpatial "MSSQL:server=localhost;database=[database-name];username=sa;password=*****;trusted_connection=yes" [path-to-shape-file]
>
> It returns an error stating:
>
> ERROR 1: Unable to find driver `MSSQLSpatial'.

I guess, GDAL/OGR version you are using on Linux is not built with
ODBC/SQL Server support.

> Is it possible to get the driver on linux? Or use an alternative driver? I’ve had a google and can’t seem to see any workarounds.
>
> The docs here (https://www.gdal.org/drv_mssqlspatial.html) talk about specifying a Driver parameter that could be
> a custom SQL Server driver, however this is in the connection string and not as a parameter for the ogr2ogr command.

Once you get GDAL/OGR built with SQL Server, install ODBC Driver for SQL Server
(there are clear docs on Microsoft site, you will find easily searching the web)

Then, try sticking the Driver option into the connection string
Driver={ODBC Driver 11 for SQL Server}
Driver={ODBC Driver 13 for SQL Server}
Driver={ODBC Driver 13.1 for SQL Server}
Driver={ODBC Driver 17 for SQL Server}
depending which version you install.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the gdal-dev mailing list