資訊工作者處理海量多元資料,地理服務 (Virtual Earth、GPS) 普及,空間資訊成為決策基礎。應用場景:零售店位置查詢、銷售區域劃分、建築規劃疊加、路徑規劃、房地產篩選、行動應用周邊搜尋等。
皆為 CLR 類型,支援點、線、多邊形,提供豐富屬性與方法 (距離、交集等)。
CREATE TABLE Districts (DistrictId int IDENTITY, DistrictName nvarchar(20), DistrictGeo geometry);
CREATE TABLE Streets (StreetId int IDENTITY, StreetName nvarchar(20), StreetGeo geometry);
INSERT INTO Districts VALUES ('Downtown', geometry::STGeomFromText('POLYGON((0 0,150 0,150 150,0 150,0 0))', 0));
INSERT INTO Streets VALUES ('First Avenue', geometry::STGeomFromText('LINESTRING(100 100,20 180,180 180)', 0));
SELECT StreetName, DistrictName FROM Districts d, Streets s WHERE s.StreetGeo.STIntersects(d.DistrictGeo) = 1;
結果顯示街道與行政區交集關係。
SQL Server 2008 以 geography/geometry 雙類型、空間索引、標準化介面與廣泛版本支援,提供全面、高效能、可擴展的空間資料平台,讓所有規模企業整合地理特徵於應用中。