Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query points using SQL Server 2008 geography type

I have a table with the geography type and I want to run a query to find all rows within 25 miles of a specific lat/long. What would the query look like to accomplish this?

like image 226
Chris Stewart Avatar asked Feb 02 '26 09:02

Chris Stewart


1 Answers

This is how I did it:

select *
from local_events
where _your_geography_column_.STDistance(geography::Point(_your_lat_,_your_long_, 4326)) < ((_your_miles_ * 1000) * 0.621371192)
like image 188
Chris Stewart Avatar answered Feb 05 '26 09:02

Chris Stewart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!