locked
Compute distance between two points and return as new field in query results. SQL R2 GEOGRAPHY RRS feed

  • Question

  • OK this doesn't seem to work - the Management Studio doesn't' like the AS or something

    what should it be ?

    I want to return all the records in the range + have a new field that shows the miles to the center point.

    ???

     

    SELECT *, geo.STDistance(GEOGRAPHY::Point(39.65337,    -105.17643,  4326) as milesaway

    FROM Venues

    WHERE geo.STDistance(GEOGRAPHY::Point(39.65337,    -105.17643,  4326)) < (25 * 1609.344)


    - 10spotdomain for all your domain and domain related needs
    Wednesday, July 27, 2011 9:12 PM

Answers

  • I think you're missing a close paren in the first line.
    Isaac Kunen, Microsoft SQL Server
    • Marked as answer by Mothermugger' Thursday, July 28, 2011 10:42 AM
    Thursday, July 28, 2011 6:00 AM

All replies

  • I think you're missing a close paren in the first line.
    Isaac Kunen, Microsoft SQL Server
    • Marked as answer by Mothermugger' Thursday, July 28, 2011 10:42 AM
    Thursday, July 28, 2011 6:00 AM
  • Dang! Issac You are right - I think I was tired at the end of the day yesterday....

    This works! I added the /1609.344 to put the results in Miles

    SELECT *, geo.STDistance(GEOGRAPHY::Point(39.65337,    -105.17643,  4326))/1609.344 as milesaway

    FROM Venues

    WHERE geo.STDistance(GEOGRAPHY::Point(39.65337,    -105.17643,  4326)) < (25 * 1609.344)



    - 10spotdomain for all your domain and domain related needs
    Thursday, July 28, 2011 10:42 AM