geography.STSymDifference
spatial method STSymDifference (instance.STSymDifference(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- geography
- Return type
- SQL Server return type: geography CLR return type: SqlGeography
Syntax at a glance
.STSymDifference ( other_geography )
Work example
Use geography.STSymDifference to return parts belonging to either shape but not both.
Check matching SRIDs and inspect boundary-only contact. Confirm both values use the same SRID before comparing or combining them.
Check your work The result contains portions belonging to exactly one input polygon; both use SRID 4326.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT a.shape.STSymDifference(b.shape).STGeometryType() AS symmetric_difference_type, a.shape.STSymDifference(b.shape).STAsText() AS symmetric_difference_wkt FROM (VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326))) AS a(shape) CROSS JOIN (VALUES (geography::STGeomFromText('POLYGON((-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326))) AS b(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.