tsql - Great Circle Distance Formula: T-SQL -
so have table bunch of different addresses in it. need proc select addresses in table within specified distance in miles passed in lat/long values.
so example of table:
- messageid - lat (float) - long (float)
proc passing in lat/long pair (both float
s well) int
(miles)
i found http://www.sqlteam.com/forums/topic.asp?topic_id=81360 calculate actual formula can't figure out modify in proc form able go through entire list of addresses , give me id
's of addresses <= miles (that pass in), lat/long pass in.
can here?
thanks!
sql server 2008
using spacial function stdistance
return distance in meters
geography::point(@lat1, @lon1, 4326).stdistance(geography::point(@lat2, @lon2, 4326))
Comments
Post a Comment