Get X Y values from Point Geometry or Geography

sql-server

Solution

For GEOGRAPHY:

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

For GEOMETRY:

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

Problem

I'm looking for the MSSQL equivalent of the following mySQL statement: ``` SELECT Y(location) as Lat, X(location) as Lon from myTable; ``` I want to get the X and Y values of my geography I have stored as a geography data type. I know `STAsText(Location) as Location` will give me the WKT... i just need the X and Y number values.

Original source