Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:27:34+00:00 2026-05-31T01:27:34+00:00

I have a list of stores with their post codes. What I need to

  • 0

I have a list of stores with their post codes. What I need to do is when a user types in a postcode on the webpage it search the db and then finds the closest 10 to that postcode.

example of data i have:

ID  = 1
Store =Halfords 
Address 1 =Unit 6b
Address 2 = Braidfute Retail Park   
Address 3   = Lanark    
Address 4 =South Lanarkshire
Postal Code = ML11 9AE
Lat = 55.6711692810059
Long = -3.77314400672913

I am able to convert the postcode into longitude and latitude, what query do i need to run to find stores within 10miles in ym table of this cord

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:27:35+00:00Added an answer on May 31, 2026 at 1:27 am

    Firstly, you’ll need the lat/lon of each postcode and store those in a table along with a geospatial representation (GEOGRAPHY, or GEOMETRY datatype). When a post code is entered by the user, you can the look up that post code in your db to find it’s location.

    You’ll also need to store a GEOGRAPHY/GEOMETRY representation of each of the stores lat/lons you currently have.

    Based on that, you can use all of SQL Server’s geospatial functionality to perform geospatial searches.

    I’ve made available on GitHub a .NET app that will import the free Ordnance Survey postcode dataset (all post codes in GB) into SQL Server, converting all the Eastings/Northings provided by it, into lat/lon and then creating a geography column. I have a full blog post on that here. The end result would be used like this:

    DECLARE @home GEOGRAPHY
    SELECT @home = GeoLocation 
    FROM dbo.PostCodeData 
    WHERE OutwardCode = 'AB12' AND InwardCode = '3CD' -- Postcode entered by user
    
    -- find all stores within 10 miles of the entered postcode
    SELECT *
    FROM dbo.Stores
    WHERE GeoLocation.STDistance(@home) <= (10 * 1609) -- 1609 = approx metres in 1 mile
    

    Hopefully, this will be a good starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a threaded server application that stores List<Item> dataList . There is a
I have a List<NameClass> that stores a collection of NameClass items with a property
I have a linked list, which stores groups of settings for my application: typedef
I have a list of users in local store that I need to update
I have a form that displays a list of systems along with their current
In my database, I have a keywords field that stores a comma-delimited list of
I have two tables, one that stores user earnings and another that stores the
I have a database of events (in the UK) and their postcodes (zip codes).
I have list of stores and when i click on any one depending on
I have a table of ratings that stores a user ID, object ID, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.