Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 STDistance (geometry Data Type)
SQL Server 2008 Books Online (August 2008)
STDistance (geometry Data Type)

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

.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);
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker