Find address using radius in SQL with geography

I have below table table1

 id  lat         lng         adress        radiusmeter   geograpghy
 1  18.20      73.020        A                           t43gv4b4b3j24vgh3f4
 2  18.30      74.120        B               200        jhg324324jg234jhg2
 3  23.20      64.320        C                          kjh234234jkh234kjh
 4  25.20      30.400        D               500        jhgjh4545jhg344345

if I want to find address for lat long 18.20,73.020 and 18.70,74.020

then I want to serach data like for id 1 and 3 default STDistance<50 meter for 2 distance will be 200 and for id 4 distance will be 500 meter

currtly I search address like below query

 SELECT TOP 1      adress    FROM table1 WITH(index(SpatialIndex_Area))  
    WHERE geography.STDistance(adresGeo) <50  
 ORDER BY geography.STDistance(adresGeo)) as Address,

adresGeo is geography of searching lat long

more ▼

asked Nov 08, 2017 at 08:15 AM in Default

avatar image

21 1 5

(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Nov 08, 2017 at 08:15 AM

Seen: 33 times

Last Updated: Nov 08, 2017 at 10:41 AM

Copyright 2018 Redgate Software. Privacy Policy