There are multiple algorithms to calculate distance on sphere, but we use following:
create function GetDistance(
@latitudeFrom decimal(30,10),
@longitudeFrom decimal(30,10),
@latitudeTo decimal(30,10),
@longitudeTo decimal(30,10)
)
RETURNS float
AS
BEGIN
DECLARE @distance float
SET @distance = ROUND(6378.137 * ACOS(
convert(decimal(30,10),
(SIN(RADIANS(@latitudeFrom)) * SIN(RADIANS(@latitudeTo))) +
(COS(RADIANS(@latitudeFrom)) * COS(RADIANS(@latitudeTo)) *
COS(RADIANS(@longitudeTo) - RADIANS(@longitudeFrom))))), 15)
RETURN @distance
END
go
(where 6378.137 - is Earth's radius)
So now when you can calculate distance between 2 points on Earth you can build query
select *
from Table1, Project
where dbo.GetDistance(
Table1.lat, Table1.lon,
Project.lat, Project.lon) < @YouRadius
where @YouRadius - parameterized radius of your circle