Trong SQL Server 2012:
SELECT geometry::UnionAggregate(geomcolumn) FROM YourTable;
Trong SQL Server 2008 / R2:
DECLARE @g = geometry::STGeomFromText('GEOMETRYCOLLECTION EMPTY', YourSRID);
SELECT @g = @g.STUnion(geomcolum) FROM YourTable;
Trong SQL Server 2012:
SELECT geometry::UnionAggregate(geomcolumn) FROM YourTable;
Trong SQL Server 2008 / R2:
DECLARE @g = geometry::STGeomFromText('GEOMETRYCOLLECTION EMPTY', YourSRID);
SELECT @g = @g.STUnion(geomcolum) FROM YourTable;