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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:01:15+00:00 2026-06-15T11:01:15+00:00

After bringing in a series of Shapefiles into SQL Server 2008R2 we are looking

  • 0

After bringing in a series of Shapefiles into SQL Server 2008R2 we are looking to grab the min and maximum points for a series of polygons in a table.

Without aggregate functions like STExtent in SQL Server 2008R2 how can one determine the min and maximum points?

This blog post points to a series of options:
http://alastaira.wordpress.com/2011/07/26/determining-the-geographic-extent-of-spatial-features-in-a-sql-server-table/

  • Option #1 : With a Cursor
  • Option #2 : CLR Function
  • Option #3 : CTE
  • Option #4 : Persisted Envelopes

An example:

BEGIN TRAN
  CREATE TABLE #Lines
  (
    ID INT IDENTITY(1,1)
    ,Poly GEOMETRY NULL
  );

  INSERT INTO #Lines
    (Poly)
  VALUES
    (geometry::STGeomFromText('LINESTRING(0 0, 2 3)', 0));

  INSERT INTO #Lines
    (Poly)
  VALUES
    (geometry::STGeomFromText('LINESTRING(1 1, 2 4)',0));

  --How can i get the min and max x and y points?
      --(e.g. for this example Xmin = 0, Xmax = 2, Ymin = 0, Ymax = 4)


  DROP TABLE #Lines 
COMMIT
  • 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-15T11:01:16+00:00Added an answer on June 15, 2026 at 11:01 am

    I agree with the author of the aforementioned (and linked) blog post that persistence envelopes is a good solution given the lack of change in the data.

    Below I have the edited the example to answer the question with that implementation.

    BEGIN TRAN
      CREATE TABLE #Lines
      (
        ID INT IDENTITY(1,1)
        ,Poly GEOMETRY NULL
      );
    
     INSERT INTO #Lines
      (Poly)
     VALUES
      (geometry::STGeomFromText('LINESTRING(0 0, 2 3)', 0));
    
     INSERT INTO #Lines
      (Poly)
     VALUES
      (geometry::STGeomFromText('LINESTRING(1 1, 2 4)',0));
    
    
     --Using option 4 of persisted envelopes
    
     ALTER TABLE #Lines
       ADD
         MinX AS (CONVERT(int, Poly.STEnvelope().STPointN((1)).STX, 0)) PERSISTED,
         MinY AS (CONVERT(int, Poly.STEnvelope().STPointN((1)).STY, 0)) PERSISTED,
         MaxX AS (CONVERT(int, Poly.STEnvelope().STPointN((3)).STX, 0)) PERSISTED,
         MaxY AS (CONVERT(int, Poly.STEnvelope().STPointN((3)).STY, 0)) PERSISTED;
    
     SELECT
       MIN(MinX) AS [X Minimum]
       ,MIN(MinY) AS [Y Minimum]
       ,MAX(MaxX) AS [X Maximum]
       ,MAX(MaxY) AS [Y Maximum]    
     FROM #Lines
    
     DROP TABLE #Lines 
    COMMIT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After moving away from Biztalk since BT2006, we're looking at bringing it back into
After bringing CardIO (iOS XCode) into my build, I am receiving a link error
I renamed the table by sp_RENAME (SQL SERVER 2008) sp_RENAME 'dbname.scname.oldtblname' 'dbname.scname.newtblnam' The resulting
After deploying WCF server (svc) on my Server, I have got this message when
After discovering about Javascript namespaces, I tried to implement them but I run into
After a system upgrade i am no longer able to start my tomcat5 server.
After I deployed WCF web service to Windows server 2008 R2, I was able
I've been tasked with bringing a site up-to-date with modern standards. After reading the
I'm bringing focus to a UITextView after setting its .hidden property to NO. When
after looking up the 'Defining launch modes' section of the 'Tasks and Back Stack'

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.