title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | f1_keywords | helpviewer_keywords | dev_langs | monikerRange | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STDistance (geometry Data Type) |
STDistance (geometry Data Type) |
MladjoA |
mlandzic |
03/14/2017 |
sql |
t-sql |
reference |
|
|
|
|
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric |
[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]
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.
[!INCLUDEssNoVersion] 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);