Spatial Support in SQL Server

SQL Server 2008 adds new spatial data types and methods for storing and handling spatial data. The two new data types are GEOMETRY and GEOGRAPHY. This new functionality provides great capabilities to process spatial data.

Here is one brief example to demonstrate the GEOGRAPHY data type and one of the related methods. The code below finds if a geographical location defined by latitude and longitude coordinates is within a geographical region defined by a polygon.




SET @point = geography::Parse('POINT(49.274138 73.098562)');

SET @polygon = geography::Parse('POLYGON((47.0 90.0, 47.0 73.0, 50.0 52.0, 50.0 54.0, 47.0 90.0))');


SELECT @polygon.STIntersects(@point);

Additional resources:

Working with Spatial Data

Geometry Data Type Method Reference

Geography Data Type Method Reference

Working with Spatial Indexes

1 reply
  1. goko
    goko says:

    Hi Plamen,
    I'd like to make a simple spatial based application on a mobile frame platform. Right now the local database on the phone is MS SQL Server Compact Edition 3.5 and the external db is IBM DB2 9.7. I will have soon some table with polygons and offices with latitudes and longitudes. The goal is to find (and possibly to display) the routes between 2 points, that in addition should belong to one region of the state. I am beginner in this, my question is just where to start, what do I need, reference etc.
    Thanks, Georgi


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *