How can i control the latitude and the longitude of the Team and the Customer with reasonable error margin from the Job Table?

if the two values are close to eachother i will return it "true", if not "false"

Job Table (like this) :

```
JobID CustomerID TeamID
2 13 1
3 13 2
```

Team Table :

```
TeamID Latitude Longitude
1 41.019 28.965
2 42.019 27.165
```

Customer Table

```
ID Latitude Longitude
13 13.557 13.667
```

The function:

```
CREATE FUNCTION dbo.DictanceKM(@lat1 FLOAT, @lat2 FLOAT, @lon1 FLOAT, @lon2 FLOAT)
RETURNS FLOAT
AS
BEGIN
RETURN ACOS(SIN(PI()*@lat1/180.0)*SIN(PI()*@lat2/180.0)+COS(PI()*@lat1/180.0)*COS(PI()*@lat2/180.0)*COS(PI()*@lon2/180.0-PI()*@lon1/180.0))*6371
END
```