Skip to main content

Spatial index in SQL Server

Spatial index
The spatial index is designed to handle indexing spatial type column and has been available since SQL Server 2008. A spatial data-type is used to data storage for geography and geometry.
Handed devices like mobile supported the features like GPS and Maps, the need to store spatial data in a relational database is more than ever before. Spatial data identifies places and boundaries on the earth. Microsoft added support in SQL Server 2008 with the introduction of native spatial data types to represent spatial objects. At the same time, Microsoft added the required functionality to access and index spatial data.

The spatial data type of SQL Server allows us to store spatial objects and make them available for an application. SQL Server supports two spatial data types:

1.      Geometry: coordinates X and Y, which represent lines, points or polygon.
2.      Geography: Coordinates latitude and longitude which represents lines, points or polygons.

How to create a spatial index?
The following script will help you to create a spatial index in SQL Server.



CREATE SPATIAL INDEX IX_Address_SpatialLocation ON Person.Address(SpatialLocation);