I have a Table with some spatial Data in MS SQL Server. The datatype of the spatial column is
I'm trying to get the closest data from an input file using the following query:
DECLARE @g geometry; SET @g= geometry::STGeomFromText('POINT(-74.19432 43.745)', 4326); SELECT TOP(1) Shape, Shape.ToString(), UID, Colour, Shape.STDistance(@g) FROM dbo.roads WHERE Shape.STDistance(@g) IS NOT NULL ORDER BY Shape.STDistance(@g);
This query runs successfully, but I want the distance between my input point and the Shape in meters; Right now the value is in Decimal Degrees, since my data is WGS84-lat-long.
To get Distance in Meters, I need to convert the
geometry on the fly to
I can't find the syntax to do this Casting in the Select Clause of the Query.
How do I temporarily cast the geometry to geography on the fly?