Tuesday, April 26, 2016

Stored Procedure in sql server to get distance from you current location lattitue and longitude

Create procedure Proc_GetLocations
(
@lat decimal=00.0,
@lng decimal=00.0
)as 
begin
select  BM.Name, BL.Lat,BL.Lng,
Geography::Point(@lat, @lng, 4326).STDistance(Geography::Point(Lat, Lng, 4326)) as Distance_Meters
from Location as BL inner join Master as BM on BL.BusinessId=BM.BusinessID
order by Distance_Meters
end

No comments:

Post a Comment