0

I have the following table in sqlfiddle

a   b   alat    alon    blat    blon
A   X   40      -76      26     -80
B   Y   41      -74      24     -81
C   Z   42      -73      24     -80

I would like to use a select query to add a numeric distance column.

My current try is

select a,b,alat,alon,blat,blon,
GEOGRAPHY::Point(alat, alon,4326).STDistance(GEOGRAPHY::Point(blat, blon, 4326))
from lat_lon

but I get the error

Incorrect syntax near 'GEOGRAPHY'

How can I include a distance column in my select statement?

Alex
  • 2,603
  • 4
  • 40
  • 73

2 Answers2

0

Your query is running fine (please see screenshot below):

enter image description here

sacse
  • 3,634
  • 2
  • 15
  • 24
0

How can I include a distance column in my select statement?

Check your select statement what are you running, it might be missing . before STDistance.

enter image description here

And SQL you posted here working fine..

enter image description here

CR241
  • 2,293
  • 1
  • 12
  • 30