SELECT a.Remark,b.stationcode otherstationid, CAST( a.GeoCol.STDistance(b.GeoCol) AS int) distance FROM ALLbaseStation a JOIN allotherStation b ON 1=1 WHERE CAST( a.GeoCol.STDistance(b.GeoCol) AS int)<5000