SQL - Distance to nearest premise using lat/long

Copper Contributor

Hi all, I am looking to create a function that i can then use on two tables. The first with UPRN (unique premise ref.), Latitude and Longitude coordinates and type A. The second identical but of type B.

 

I need a function that then lists, for each UPRN in table 1, the nearest UPRNs (in order of distance) from table 2. I have looked at using the Geography type but am unsure how to build it into a function that i can then use on table 1. Can anyone please help?

5 Replies
SVP Quelqu'un peut m aider ici comment faire un tableau dynamique croisé a partir d une base de donné sur excel

Thanks @HotCakeX!

 

@Tippelschniff175,  

Hello! You've posted your question in the Community Discussion space, which is intended for discussion around the Tech Community website itself, not product questions. I'm moving your question to the SQL Server space - please post SQL Server questions here in the future. 

@Ibrahimtoure20: Thanks for your question.

 

As your question is not related to this particular inquiry (as per our code of conduct, we like to stay on topic), and you've posted your question in a separate thread, could you please monitor that thread instead to help answer your question?

 

Appreciate that!