geometry.STDistance
spatial method STDistance (instance.STDistance(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- float
- Return type
- SQL Server return type: float CLR return type: SqlDouble
Syntax at a glance
.STDistance ( other_geometry )
Work example
Use geometry.STDistance to measure minimum distance between two shapes.
For geometry use coordinate units. For geography verify SRID units with known points. Confirm both values use the same SRID before comparing or combining them.
Check your work Different SRIDs can produce null and units follow the spatial type. Incompatible SRIDs can make a two-instance result null. For this geometry result, verify coordinate units in the planar reference.
Practice SQL
Open in SQL FlowSELECT geometry::Point(2, 3, 0).STDistance(geometry::Point(5, 7, 0)) AS distance_units;
Open Microsoft Learn for full syntax, permissions, and details for your version.