How to store longitude & latitude as a geography in sql server 2014?

后端 未结 4 1296
慢半拍i
慢半拍i 2020-12-10 02:16

I have locations in longitude and latitude coordinates. My goal is eventually to be able to select all rows from myTable Where distance is less than 2km.

  1. Ho

4条回答
  •  臣服心动
    2020-12-10 02:41

    You can convert lat and long to a point and save it in table.

    Declare @geo Geography, @Lat varchar(10), @long varchar(10)

    SET @Lat = '34.738925' SET @Long = '-92.39764'

    SET @geo= geography::Point(@LAT, @LONG, 4326)

提交回复
热议问题