Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

STWithin (geography Data Type)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns 1 if a geography instance is spatially within another geography instance; otherwise, returns 0.

.STWithin ( other_geography )

other_geography

Is another geography instance to compare against the instance on which STWithin() is invoked.

SQL Server return type: bit

CLR return type: SqlBoolean

This method always returns null if the spatial reference IDs (SRIDs) of the geography instances do not match.

The following example uses STWithin() to test two geography instances to see if the first instance is completely within the second instance.

DECLARE @g geography;
DECLARE @h geography;
SET @g = geography::Parse('POLYGON ((-120.533 46.566, -118.283 46.1, -122.3 47.45, -120.533 46.566))');
SET @h = geography::Parse('CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (-122.200928 47.454094, -122.810669 47.00648, -122.942505 46.687131, -121.14624 45.786679, -119.119263 46.183634), (-119.119263 46.183634, -119.273071 47.107523), CIRCULARSTRING (-119.273071 47.107523, -120.640869 47.569114, -122.200928 47.454094)))');
SELECT @g.STWithin(@h);

Community Additions

ADD
Show:
© 2015 Microsoft