联合 SQL Server 表中的所有几何图形,例如 Postgres 中的 GeomUnion
预先澄清一下:我说的是联合几何,而不是 SQL 关键字 UNION
。
我正在尝试将一些空间数据从带有 PostGIS 的 Postgres 移动到 SQL Server 2008。一切都很好,直到我看到这样的语句:
SELECT GeomUnion(the_geom) FROM some_table
This unions all geography in that column and return it as a result (类似于 COUNT
有效)。据我所知,SQL Server 只有 STUnion 函数,它将一种几何图形与另一种几何图形结合起来。有什么方法可以做类似 Postgres 的事情吗?
如果有帮助的话,STUnion
函数的工作原理如下:
SELECT first_geometry_column.STUnion(second_geometry_column) FROM some_table
Just to clarify up-front: I'm talking about unioning geometry, not the SQL keyword UNION
.
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:
SELECT GeomUnion(the_geom) FROM some_table
This unions all geometry in that column and return it as one result (similar to how COUNT
works). As far I know, SQL Server only has the STUnion
function, which unions one geometry with another. Is there any way to do something similar to the Postgres way?
If it helps, the STUnion
function works like this:
SELECT first_geometry_column.STUnion(second_geometry_column) FROM some_table
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UnionAggregate函数只有SQL2012吗?
嗯,猜是这样。 http://technet.microsoft.com/en-us/library/ff929095.aspx
Is the UnionAggregate function SQL2012 only?
Hmm guess so. http://technet.microsoft.com/en-us/library/ff929095.aspx
我最终这样做的方式是使用变量:
它不是那么好,但它有效。
The way I ended up doing this is with variables:
It's not as nice, but it works.
最好的选择是创建一个 CLR 函数来支持聚合。有几个现有的解决方案:
Your best option is to create a CLR function to support the aggregate. There are a couple of existing solutions: