In the past I have used shape2sql to import shape files into SQL Server.
I tried that route again on a newer Windows 10 box, and nothing seems to happen when trying to use that application.
Any suggestions for either getting shape2sql to work, or alternative ways to upload shape files into SQL Server?
So, it turns out that ogr2ogr has the ability to import directly into a SQL Server database now. I created a temporary database and did the following:
ogr2ogr -overwrite -f MSSQLSpatial -lco “GEOM_TYPE=geography” -a_srs "EPSG:4326" "MSSQL:server=.;database=temp_import;trusted_connection=yes" "[path to shape file]"
I've managed to import successfully on remote server. Here goes procedure
-a_srs "EPSG:3765":Open QGIS Desktop 3.10.5, open new project and drag-drop your shape file to Layers left sidebar. Right click on that layer and go to Properties. There you will be able to read your -a_srs information.

Run command in CMD:
C:\Program Files\QGIS 3.10\bin>ogr2ogr -progress -f "MSSQLSpatial" "MSSQL:server=xxx.xxx.xxx.xxx,yyyy;database=yourDB;UID=yourUse;PWD=yourPassword" "C:\Users\Username\Desktop\ShapeFiles\Name_of_shape_file.shp" -a_srs "EPSG:3765" -lco PRECISION=NO
Where xxx.xxx.xxx.xxx - IP address of your server
yyyy - port number of your server if you are running SQL Server on different port than standard (I think you can omit that in case you are)
Output: 0...10...20...30...40...50...Warning 1: Ring Self-intersection at or near point 664451.64629999956 5053409.8562000087 60...70...80...90...100 - done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With