STRelate (geometry Data Type)
Collapse the table of content
Expand the table of content

STRelate (geometry Data Type)


Applies To: SQL Server 2014, SQL Server 2016 Preview

Returns 1 if a geometry instance is related to another geometry instance, where the relationship is defined by a Dimensionally Extended 9 Intersection Model (DE-9IM) pattern matrix value; otherwise, returns 0.

.STRelate ( other_geometry, intersection_pattern_matrix )


Is another geometry instance to compare against the instance on which STRelate() is invoked.


Is a string of type nchar(9) encoding acceptable values for the DE-9IM pattern matrix device between the two geometry instances.

This method always returns null if the spatial reference IDs (SRIDs) of the geometry instances do not match. This method will throw an ArgumentException if the matrix is not well-formed.

SQL Server return type: bit

CLR return type: SqlBoolean

The following example uses STRelate() to test two geometry instances for spatial disjoint using an explicit DE-9IM pattern.

DECLARE @g geometry;
DECLARE @h geometry;
SET @g = geometry::STGeomFromText('LINESTRING(0 2, 2 0, 4 2)', 0);
SET @h = geometry::STGeomFromText('POINT(5 5)', 0);
SELECT @g.STRelate(@h, 'FF*FF****');

Community Additions

© 2015 Microsoft