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 8531687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:32:40+00:00 2026-06-11T09:32:40+00:00

I am very new to the spatial realm of SQL Server and need some

  • 0

I am very new to the spatial realm of SQL Server and need some help. I have a waypoint organizing app and I am trying to generate some queries that follow along the premise of finding waypoints that are part of geographic polygons like lakes, rivers, etc. I have preloaded my tables with data I have downloaded. I used shape2sql.exe to load shapefiles into the appropriate db tables.

Tables are as follows:
Water table – id, name, geog(geography data type)
State table – id, state_name, state_abbr, geog(geography data type)
County table – id, name, state_name, geog(geography data type)
Waypoint table – id, name, lat, lon, waterid

How do I write queries against these tables to return things like:
– all waypoints in ‘michigan’
– all waypoints on ‘bass lake’ in ‘montcalm’ county in ‘michigan’ (there are multiple bass lakes in michigan and the country hence the county/state part)
– auto assign the water id column of the waypoint table by “processing” a group of waypoints and finding what lake they actually belong to
– etc.

Thanks!

Learned so far:
select geog.ToString() as Points, geog.STArea() as Area, geog.STLength() as Length
from water
where name like ‘%bass lake%’ and STATE = ‘mi’

will return the record for Bass Lake and the polygon with the actual coordinates for the lake.
POLYGON ((-87.670498549804691 46.304831340698243, -87.670543549804691 46.307117340698241, -87.676573549804687 46.313480340698241, -87.68120854980468 46.314821340698245, -87.685168549804686 46.315703340698242, -87.6877605498047 46.313390340698241, -87.685051549804683 46.308827340698244, -87.682360549804685 46.305650340698243, -87.677734549804683 46.304768340698246, -87.674440549804686 46.304336340698242, -87.670498549804691 46.304831340698243)) 1022083.96662664 4027.52433709888

  • 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-11T09:32:41+00:00Added an answer on June 11, 2026 at 9:32 am

    Ok – learning as I go so here are some answers to my own questions for anyone what would like to know.

    Here is one query for finding various waypoints with conditions in the where clause:
    SELECT * FROM WaypointTable wp
    JOIN WaterTable w
    ON wp.geogcolumn.STIntersects(w.geogcolumn) = 1
    WHERE w.name LIKE ‘%bass lake%’
    AND w.state = ‘mi’;

    Here is a query for assigning water id’s to waypoints based on where they ‘fit’:
    UPDATE WaypointTable wp
    SET WaterID = (
    SELECT ID
    FROM WaterTable
    WHERE geogcolumns.STIntersects(wp.geogcolumn) = 1
    );

    Both of these queries work extremely well and fast! Love it!

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

Sidebar

Related Questions

Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
Very new to Business Objects, but I have a .NET background and PL/SQL background.
Am very New to Web Page Development. In my website i have the help
im very new to this and have a very basic knowledge php and SQL
Very new to SQL Server. I am needing to develop a SQL Server database
Very new to PHP5 and have some problems still. I figured out how to
Im very new to SQL but need to write a query to do the
Im very new to mysql, and any help would be much appreciated! I have
Very new to python and can't understand why this isn't working. I have a
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to

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.