How to prevent duplicate or similar data from getting processed?
Try adding And t1.ID &gt; t2.ID to the where clause , it will make sure that the join happens once .
To the following query

SELECT t1.place_name, t1.region_name, t2.place_name, t2.region_name, loc.FN_CalcAerialDistance(t1.latitude, t1.longitude, t2.latitude, t2.longitude) -- Function calculates Distance 
FROM @postal1 as t1 CROSS JOIN @postal2 as t2 
WHERE t1.latitude &lt;&gt; t2.latitude and t1.longitude &lt;&gt; t2.longitude