Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
STDistance (geometry Data Type)
Collapse the table of content
Expand the table of content

STDistance (geometry Data Type)

 

Applies To: SQL Server 2014, SQL Server 2016 Preview

Returns the shortest distance between a point in a geometry instance and a point in another geometry instance.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.


.STDistance ( other_geometry )

other_geometry

Is another geometry instance from which to measure the distance between the instance on which STDistance() is invoked. If other_geometry is an empty set, STDistance() returns null.

SQL Server return type: float

CLR return type: SqlDouble

STDistance() always returns null if the spatial reference IDs (SRIDs) of the geometry instances do not match.

DECLARE @g geometry;
DECLARE @h geometry;
SET @g = geometry::STGeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))', 0);
SET @h = geometry::STGeomFromText('POINT(10 10)', 0);
SELECT @g.STDistance(@h);

Community Additions

ADD
Show:
© 2015 Microsoft