適用於:SQL Server
Azure SQL Database
Azure SQL Managed Instance
Microsoft Fabric 中的 SQL 資料庫
在一組 geometry 物件上執行聯集作業。
Syntax
UnionAggregate ( geometry_operand )
Arguments
geometry_operand
這是 geometry 類型資料表資料行,可保留要在其上執行聯集作業的一組 geometry 物件。
傳回型別
SQL Server 傳回類型:geometry
Exceptions
輸入的值無效時,會擲回 FormatException。 請參閱 STIsValid (geometry 資料類型)
Remarks
當輸入是空的或輸入具有不同 SRID 時,此方法會傳回 null。 請參閱空間參考識別碼 (SRID)
此方法會忽略 null 輸入。
Note
如果所有輸入的值都為 null,此方法就會傳回 null。
Examples
下列範例會傳回資料表變數中 geometry 物件集的聯集。
-- Setup table variable for UnionAggregate example
DECLARE @Geom TABLE
(
shape geometry,
shapeType nvarchar(50)
);
INSERT INTO @Geom(shape,shapeType)
VALUES('CURVEPOLYGON(CIRCULARSTRING(2 3, 4 1, 6 3, 4 5, 2 3))', 'Circle'),
('POLYGON((1 1, 4 1, 4 5, 1 5, 1 1))', 'Rectangle');
-- Perform UnionAggregate on @Geom.shape column
SELECT geometry::UnionAggregate(shape).ToString()
FROM @Geom;