I have a table with a single column of geometry
type, containing polygons. How do I get the union of all the polygons in the table?
In SQL Server 2012:
SELECT geometry::UnionAggregate(geomcolumn) FROM YourTable;
In SQL Server 2008/R2:
DECLARE @g = geometry::STGeomFromText('GEOMETRYCOLLECTION EMPTY', YourSRID);
SELECT @g = @g.STUnion(geomcolum) FROM YourTable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With