从Point Geometry或Geography中获取X Y值

时间:2012-06-01 19:08:48

标签: sql-server

我正在寻找以下mySQL语句的MSSQL等价物:

SELECT Y(location) as Lat, X(location) as Lon from myTable;

我想获取我作为地理数据类型存储的地理位置的X和Y值。

我知道STAsText(Location) as Location会给我WKT ......我只需要X和Y数字值。

1 个答案:

答案 0 :(得分:43)

对于地理学:

SELECT location.Lat as Lat, location.Long as Lon from myTable;

对于GEOMETRY:

SELECT location.STY as Lat, location.STX as Lon from myTable;