Haversine formula in SQL
Why do you need the function? To measure the distance (in miles) between two points? Then you want to select all points of a certain type and order them by distance from a given origin.

With a CTE (common table expression)  you can simplify things a lot too.

But, the real issue, is that you should use the functions already available in the geography datatype: STDistance. This STDistance function returns the 'LineString' distance, which is 0.25% accurate to the geodesic distance. Additionally, this is better than the 0.5% accuracy of the Haversine distance.

So, by the sounds of it, you have horribly overcomplicated this process. Consider this (SQLFiddle example here too):

Select s.FEATURE_NAME as SName,
       s.GeoLocation.Lat as SLat,
       s.GeoLocation.Long as SLong,
       t.FEATURE_NAME as TName,
       t.GeoLocation.Lat as TLat,
       t.GeoLocation.Long as TLong,
       s.GeoLocation.STDistance(t.GeoLocation) * 0.00062137 as Distance
from Features s,
     Features t
where s.FEATURE_NAME = 'Seattle'
  and s.FEATURE_CLASS = 'Populated Place'
  and t.FEATURE_CLASS = 'Lake'
order by Distance desc