Union all geometry in a SQL Server table like GeomUnion in Postgres

跟風遠走 提交于 2019-12-01 03:26:29

Is the UnionAggregate function SQL2012 only?

SELECT geography::UnionAggregate( geometry ) FROM some_table

Hmm guess so. http://technet.microsoft.com/en-us/library/ff929095.aspx

The way I ended up doing this is with variables:

DECLARE @Shape GEOMETRY
SET @Shape = GEOMETRY::STGeomFromText('GEOMETRYCOLLECTION EMPTY', @MySrid)

SELECT @Shape = @Shape.STUnion(Shape)
  FROM MyShapeTable

It's not as nice, but it works.

Your best option is to create a CLR function to support the aggregate. There are a couple of existing solutions:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!