How to load spatial data into SQL Server 2008 from .Net
I have been working on a project which made use of the spatial data type geography within SQL Server 2008. An issue that I had was how to load the geography data from a KML file into SQL Server 2008. Currently there is no out of the box tools to do this. There is a 3 rd party tool, Safe FME, which offer either their own tool or components which extend integration services. This was overkill for my issues as I only had to do it once. So I wrote a console application which parses the KML file to extract the point data convert it to a SqlGeography type and store it in the database. To use the SqlGeography C# type you need to add reference to the following name space: Microsoft.SqlServer.Types. This can be found in the following dll: Microsoft.SqlServer.Types.dll Then use the following code to create the c# sqlgeography type: 1: // use SqlGeographyBuilder to help create the SqlGeography type 2: SqlGeographyBuilder geographyBuilder = new SqlGeographyBuilder(); 3: s...