• Possibly similar I adapted some code to create my version:

    (ACOS(COS(RADIANS(90-SD.StuLat)) *COS(RADIANS(90-BS.SchLat)) +SIN(RADIANS(90-SD.StuLat)) *SIN(RADIANS(90-BS.SchLat)) *COS(RADIANS(SD.StuLong-BS.SchLong))) *3958.756) AS DISTANCE_M

    Your version seems more robust and I look forward to playing with it.

    I'm new to SQL so haven't gotten my head round variables and spatial data types so this in the Select statement worked.

    I used it to work out how far kids travelled to school. And by multiplying it by 1.35 it seemed to give a more accurate distance to account for the fact people don't travel in straight lines.

    Many thanks for sharing.