///////////////// Method I
------To search by kilometers instead of miles just multiply by 1.60934
select * from(SELECT locationname,locationcode,lat,long,(60 * 1.1515 * (180/pi()) *
cos(radians(@lat))*cos(radians(Lat)) * cos(radians(Long) - radians(@lng))+ sin (radians(@lat)) * sin(radians(lat))
) AS distance FROM mstlocation where SW_GW=2)dt
///////////////// Method II
------ 1 miles= 1.60934 Kms and pi()==22/7 or 3.14159265358979323846, 180= degree
select * from(
acos(sin((@lat*pi()/180)) * sin((lat*pi()/180)) + cos((@lat*pi()/180)) * cos((lat*pi()/180)) * cos(((@lng- long) * pi()/180)))
* (180/pi()) * 60 * 1.1515 *1.60934) as distance FROM mstlocation where SW_GW=2 and statecode='10')dt where distance<=@Distance
///////////// Indicators
----@lng – this is the variable where passing the longitude of the point.
----@lat – this is the variable where passing the longitude of the point.
----@Distance – this is the distance that you would like to find all the markers.
----table – this is the table… you’ll want to replace that with your table name.
----lat – this is the field (latitude) of my table..
----long – this is the field (longitude) of my table.