I have found a bunch of answers for this question using mysql , but I wasn\'t able to convert anything into a query ms sql 2008 can use. I have a longitude and latitude col
Since you're on SQL 2008, consider using the native geospatial capabilities. You can do fancy things like:
yourPoint.STDistance(@otherPoint) <= @distance efficientLike so:
alter table [yourTable] add [p] as geography::Point(Latitude, Longitude, 4326) persisted;
create spatial index [yourSpatialIndex] on [yourTable] ([p])
declare @Latitude float = , @Longitude float = ;
declare @point geography = geography::Point(@Latitude, @Longitude, 4326);
declare @distance int = ;
select * from [yourTable] where @point.STDistance([p]) <= @distance;