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

  • SEARCH
  • Home
  • 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 9237233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:29:25+00:00 2026-06-18T07:29:25+00:00

Given the following data, would it be possible, and if so which would be

  • 0

Given the following data, would it be possible, and if so which would be the most efficient method of determining whether the location ‘Shurdington’ in the first table is contained within the given radius’s of any of the locations in the second table.

The GeoData column is of the ‘geography’ type, so using SQL Servers spatial features are an option as well as using latitude and longitude.

Location      GeoData       Latitude    Longitude
===========================================================
Shurdington   XXXXXXXXXX    51.8677979  -2.113189

ID  Location            GeoData     Latitude    Longitude   Radius
==============================================================================
1000    Gloucester      XXXXXXXXXX  51.8907127  -2.274598   10
1001    Leafield        XXXXXXXXXX  51.8360519  -1.537438   10
1002    Wotherton       XXXXXXXXXX  52.5975151  -3.061798   5
1004    Nether Langwith XXXXXXXXXX  53.2275276  -1.212108   20
1005    Bromley         XXXXXXXXXX  51.4152069  0.0292294   10

Any assistance is greatly apprecieded.

  • 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-06-18T07:29:27+00:00Added an answer on June 18, 2026 at 7:29 am

    Create Data

    CREATE TABLE #Data (
        Id int,
        Location nvarchar(50),
        Latitude decimal(10,5),
        Longitude decimal(10,5),
        Radius int
    )
    
    INSERT #Data (Id,Location,Latitude,Longitude,Radius) VALUES 
    (1000,'Gloucester', 51.8907127 ,-2.274598  , 20), -- Increased to 20
    (1001,'Leafield', 51.8360519 , -1.537438  , 10),
    (1002,'Wotherton', 52.5975151,  -3.061798  , 5),
    (1004,'Nether Langwith', 53.2275276 , -1.212108  , 20),
    (1005,'Bromley', 51.4152069 , 0.0292294  , 10)
    

    Test

    Declare your point of interest as a POINT

    DECLARE @p GEOGRAPHY = GEOGRAPHY::STGeomFromText('POINT(-2.113189 51.8677979)', 4326);
    

    To find out if it is in the radius of another point:

    -- First create a Point.
    DECLARE @point GEOGRAPHY = GEOGRAPHY::STGeomFromText('POINT(-2.27460 51.89071)', 4326);
    -- Buffer the point (meters) and check if the 1st point intersects
    SELECT @point.STBuffer(50000).STIntersects(@p)
    

    Combining it all into a single query:

    select  *,
            GEOGRAPHY::STGeomFromText('POINT('+ 
                convert(nvarchar(20), Longitude)+' '+
                convert( nvarchar(20), Latitude)+')', 4326)
            .STBuffer(Radius * 1000).STIntersects(@p) as [Intersects]
    from    #Data  
    

    Gives:

    Id      Location        Latitude    Longitude   Radius  Intersects
    1000    Gloucester      51.89071    -2.27460    20      1
    1001    Leafield        51.83605    -1.53744    10      0
    1002    Wotherton       52.59752    -3.06180    5       0
    1004    Nether Langwith 53.22753    -1.21211    20      0
    1005    Bromley         51.41521    0.02923     10      0
    

    Re: Efficiency. With some correct indexing it appears SQL’s spatial indexes can be very quick

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

Sidebar

Related Questions

I was asked the following Question: How would you store the data given below(which
Given the following schema / data / output how would I format a SQL
Given the following data/schema: DECLARE @t1 TABLE ( Id int NOT NULL ) DECLARE
Given the following example data: Users +--------------------------------------------------+ | ID | First Name | Last
Given the following table and data. create table prices (productKey int ,PriceType char(10) ,BeginDate
Given a simple table with the following data: id | result | played ----+--------+------------
I have an odd linq subquery issue. Given the following data structure: Parents Children
Given the following JSON data: [ { pk: 2, model: corkboard.announcement, fields: { body:
Given the following simple BST definition: data Tree x = Empty | Leaf x
Given the following tree structure in Haskell: data Tree = Leaf Int | Node

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.