Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2008-10-27 : 09:26:12
|
| I have a location with longitude and lattitude.I want to search for ares within a 10 mile radius of this but dont know how to do this is SQLHave browsed many websites but they all suggest to use POW and ATAN2 which aren't recognised in SQL.This is what I have tried so far( @venue_id int)ASdeclare @postcode varchar(10)declare @lat floatdeclare @long floatdeclare @radius floatdeclare @distance float set @radius = 20SELECT @postcode = venue_postcode FROM tb_venue WHERE venue_id = @venue_idSELECT *FROM tb_properties, tb_venueWHEREProp_Visible = 1ANDtb_properties.glat >0ANDtb_properties.glong >0and@radius > ((tb_venue.venue_glat - tb_properties.glat)*(tb_venue.venue_glat - tb_properties.glat)) + ((tb_venue.venue_glat - tb_properties.glat)*(tb_venue.venue_glat - tb_properties.glat))GO |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-10-27 : 11:07:30
|
| http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81360&SearchTerms=latitu |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-27 : 11:16:01
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=112369 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-27 : 11:16:43
|
quote: Originally posted by godspeedba Have browsed many websites but they all suggest to use POW and ATAN2 which aren't recognised in SQL.
POW is spelled POWER in T-SQL and ATAN2 is spelled ATN2 in T-SQL. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|