title: Union all geometry in a SQL Server table like GeomUnion in Postgres
body: <p>Just to clarify up-front: I'm talking about unioning geometry, not the SQL keyword <code>UNION</code>.</p>
  
  <p>I'm trying to move some spatial data from Postgres with PostGIS to SQL Server 2008. It was fine until I saw a statement like this:</p>
  
  <pre><code>SELECT GeomUnion(the_geom) FROM some_table
  </code></pre>
  
  <p>This unions all geometry in that column and return it as one result (similar to how <code>COUNT</code> works). As far I know, SQL Server only has the <code>STUnion</code> function, which unions one geometry with another. Is there any way to do something similar to the Postgres way?</p>
  
  <p>If it helps, the <code>STUnion</code> function works like this:</p>
  
  <pre><code>SELECT first_geometry_column.STUnion(second_geometry_column) FROM some_table
  </code></pre>