适用于:SQL Server
Azure SQL 数据库
Azure SQL 托管实例
Microsoft Fabric 预览版中的 SQL 数据库
返回一个 geometry 实例中的点与另一个 geometry 实例中的点之间的最短距离。
Syntax
.STDistance ( other_geometry )
Arguments
other_geometry
另一个 geometry 实例,将度量该实例与调用 STDistance() 的实例之间的距离。 如果 other_geometry 为空集,则 STDistance() 返回 null。
Return Types
SQL Server 返回类型:float
CLR 返回类型:SqlDouble
Remarks
如果 STDistance() 实例的空间引用 ID (SRID) 不匹配,则 始终返回 null。
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);