Spatial Data Types And Indexing SQL Server 2008 Bob King
Data Types geometry geography Planar data geography Geodetic data (projection of the curve of the Earth) Represents points, polygons, regions, etc. in the same data type
Common Methods Contains Overlaps Distance Touches Equals Within Intersects Union DECLARE @g geometry; SET @g = geometry::STPolyFromText('POLYGON ((5 5, 10 5, 10 10, 5 5))', 0); SELECT @g.ToString();
Indexing the geo* datatypes Quad-tree based Successively smaller grid cells
Indexing the geo* datatypes Coverage masks Touched Partially Covered Interior Map a cell identifier to a primary key Map sub-cells
Searching a geo* index Select on a cell identifier using prefix matching: (T.cell LIKE I.cell + ‘%’) OR (I.cell LIKE T.cell + ‘%_’) Use existing SQL text searching optimizations