• Blog posts


    By David Crowther 



    I would like to copy a PostGIS Database Table into a SQL Server Database, what are the best steps to do this?


    In the blog below, I have outlined how to use Ogr2Ogr to load a Shapefile into a SQL Database. This is a good starting point for learning how to use OgrOgr.


    Using this updated Ogr2Ogr script below, you can also copy an existing PostGIS Database table into your SQL Database:

    ogr2ogr -OVERWRITE -f "MSSQLSpatial" "MSSQL:server=SERVERNAME;database=SQLDBNAME;trusted_connection=yes;driver=SQL Server" PG:"host=SERVERNAME port=5432 user='userid' password='password' dbname='PostGISDBNAME'" -sql "SELECT * from mways" -SkipFailures -nln "UK_Motorways".

    The above script will copy the PostGIS Database Table called ‘mways’ and insert it into your SQL Database as a table named – ‘UK_Motorways’.