Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all other postcodes or (latitude & longitude) from table near by given postcode and given radius in miles in sql server?

I have table with latitude,longitude and postcodes. I want select the records which are near by given postcode and radius in miles. e.g user will give inputs postcode = 'NW44JL' and radius = 1 mile. I need to get all the records from the table with in 1 mile radius of postcode 'NW44JL'. Can anyone help me to get this. Thanks

like image 731
Sree Avatar asked Oct 31 '22 23:10

Sree


1 Answers

For this you'll want to use the built in SPATIAL datatypes:

MSDN (Designing and Implementing Spatial Storage (Database Engine))

Try the following tutorials to get you started, written by the user @SQLMenace:

SQL Server Zipcode Latitude/Longitude proximity distance search

and

SQL Server 2008 Proximity Search With The Geography Data Type

like image 102
twoleggedhorse Avatar answered Nov 15 '22 05:11

twoleggedhorse