resp:
SELECT @lat1= latitude,
@long1 = longitude
FROM PostalCodes
WHERE PostalCode = @ZipCode
SELECT PostalCode ,DistanceInMiles
FROM
(
SELECT PostalCode, 3958.75 * ( Atan(Sqrt(1 - power(((Sin(@Lat1/57.2958) * Sin(latitude/57.2958)) +
(Cos(@Lat1/57.2958) * Cos(latitude/57.2958) * Cos((longitude/57.2958) - (@Long1/57.2958)))), 2)) /
((Sin(@Lat1/57.2958) * Sin(latitude/57.2958)) + (Cos(@Lat1/57.2958) * Cos(latitude/57.2958) *
Cos((longitude/57.2958) - (@Long1/57.2958)))))) DistanceInMiles
FROM PostalCodes
WHERE Active=1
) a
WHERE a.DistanceInMiles > -1 and a.DistanceInMiles <= @GivenMileRadius
ORDER BY DistanceInMiles