Skip to content

Latest commit

 

History

History
59 lines (46 loc) · 1.82 KB

File metadata and controls

59 lines (46 loc) · 1.82 KB
title STDistance (geometry Data Type)
description STDistance (geometry Data Type)
author MladjoA
ms.author mlandzic
ms.date 03/14/2017
ms.service sql
ms.subservice t-sql
ms.topic reference
ms.custom
ignite-2025
f1_keywords
STDistance_TSQL
STDistance (geometry Data Type)
helpviewer_keywords
STDistance (geometry Data Type)
dev_langs
TSQL
monikerRange =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb

STDistance (geometry Data Type)

[!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.

Syntax

  
.STDistance ( other_geometry )  

Arguments

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.

Return Types

[!INCLUDEssNoVersion] return type: float

CLR return type: SqlDouble

Remarks

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

Examples

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);  

See Also

Spatial Indexes Overview
OGC Methods on Geometry Instances