I've got a requirement to find the nearest n postcodes from a given post code.
Could any one guide me in finding the nearest UK postcodes from a given post code with distance
I've got a requirement to find the nearest n postcodes from a given post code.
Could any one guide me in finding the nearest UK postcodes from a given post code with distance
You'll need to deal with postcodes not representing a single point but an area, in rural places that area can be significant.
The mapping of postcodes and postal addresses to geographical points, to perform the calculation, will require access to the Postcode Address File (PAF), and the Royal Mail charges for this via various resellers. When I worked with this (more than a decade ago now) the reseller (unfortunately I now forget who) could include mapping from addresses to latitude/longitude or to OS grid reference as extra data (for additional cost over the basic PAF file).
However also look at Google Maps API and Bing Maps API: for reasonable request volumes they might do the work for you.
The postcode data has been released as part of the Ordinance Survey OpenData initiative and is called "Code-Point Open" - the data is in CSV format and provides the postcode together with the eastings and northings.
A blog post showing how to use the data in C# can be found at http://doogalbellend.blogspot.com/2010/06/importing-code-point-dataset-into-sql.html - once in SQL you should be able to use the spatial data functions to perform your query.