There are other tools, but in the process of working on something else, I put together a command line tool for loading shapefiles into Sql Server 2008. It is modeled after PostGIS’s shp2pgsql, except that it loads directly into the db instead of writing sql to stdout. Here is the usage:
- shp2sqlserver.exe -h
- Usage: shp2sqlserver.exe [OPTIONS]+ "connectionString" "path to shapefile"
- Loads a shapefile into Microsoft SQL Server 2008
- example: shp2sqlserver.exe "Data Source=.\SQLExpress2008;Initial Catalog=spatialtest;Integrated Security=true" myshape.shp
- -s, --srid=VALUE The Spatial Reference ID (SRID). If not specified it defaults to -1.
- -g, --geometry_column=VALUE The name of the geometry column
- -t, --table_name=VALUE The table name to use
- -k, --key_column=VALUE The name of the identity column to create for a primary key
- -i, --index Create a spatial index
- -l, --latlong Add spatial data as geography type
- -a, --append Append data. If not specified, table will be created
- -h, --help show this message and exit
Here is a screenshot of some spatial results in management studio. Note the holes and exterior polygons:
- This is alpha level software. I have loaded some complex shapefiles up to 20MB with it, but it could bomb on yours.
- The Shapefile loader only supports Point, Polyline, and Polygon types. It will fail on everything else (including PolygonM, etc.)
Update: This has been bundled with cumberland 0.1. Get it here.