[GIS] Find closest lat long to an input lat long (SQL Server 2008)

geometrynearest neighborsql server

I have a point cloud in my database (SQL Server 2008 spatial). That is about 6 million records. There are 3 columns: id, value, geom. What is the optimal way of getting the 'value' at input lat long??

I am new to spatial queries in SQL Server 2008. Can someone post a simple example of finding the point in geom column, matching or closest from the input lat long?

Best Answer

What you are looking for is Nearest Neighbor Query. Look at the following links, I think you will find what you are looking for.