我正在寻找以下mySQL语句的MSSQL等价物:
SELECT Y(location) as Lat, X(location) as Lon from myTable;
我想获取我作为地理数据类型存储的地理位置的X和Y值。
我知道STAsText(Location) as Location
会给我WKT ......我只需要X和Y数字值。
答案 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;