FIX: Spatial Storage geometry polygon data types with internal rings return incorrect data through different geometric operations

Article translations Article translations
Article ID: 2216497 - View products that this article applies to.
Expand all | Collapse all

On This Page

SYMPTOMS

In Microsoft SQL Server 2008 or Microsoft SQL Server 2008 R2, when you try to perform a geometry operation on a polygon that has an interior ring, the operation returns an unexpected result.

For example, you run the following script:
declare @g1 geometry = 'GEOMETRYCOLLECTION(POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 8 2, 8 8, 2 8, 2 2)))'
declare @g2 geometry = 'GEOMETRYCOLLECTION(POLYGON ((2 2, 8 2, 8 8, 2 8, 2 2)))'
select @g1.STIntersection(@g2).ToString()
When you run this script, the STIntersection method does not return the following value:
LINESTRING (2 2, 8 2, 8 8, 2 8, 2 2)
Instead, the method returns the following incorrect value:
POLYGON ((2 2, 8 2, 8 8, 2 8, 2 2))

CAUSE

This problem occurs because SQL Server 2008 or SQL Server 2008 R2 does not recognize the second ring of the Polygon in the first GeometryCollection. This problem occurs only when certain instances of SqlGeometry of type GeometryCollections that have certain ring orientations are used. The problem does not occur when the SqlGeography data type is used.

RESOLUTION

Service pack information for SQL Server 2008

To resolve this problem, obtain the latest service pack for SQL Server 2008. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
968382 How to obtain the latest service pack for SQL Server 2008

Service pack information for SQL Server 2008 R2

To resolve this problem, obtain the latest service pack for SQL Server 2008 R2. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2527041How to obtain the latest service pack for SQL Server 2008 R2

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

This problem was first corrected in SQL Server 2008 Service Pack 2 for SQL Server 2008.
This problem was first corrected in SQL Server 2008 R2 Service Pack 1 for SQL Server 2008 R2.

REFERENCES

For more information about how to work with geometry data types, visit the following Microsoft TechNet webpage:
Designing and Implementing Spatial Storage (Database Engine)

Properties

Article ID: 2216497 - Last Review: April 22, 2011 - Revision: 2.0
APPLIES TO
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Standard
Keywords: 
kbprb kbsurveynew kbpubtypekc kbcode KB2216497

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com