Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > CREATE TABLE dbo.t > ( > n varchar(100) NOT NULL > , i geometry NOT NULL > ); > > INSERT INTO dbo.t (n, i) > VALUES ('poly1', geometry::STGeomFromText('POLYGON ((1 2, 1 4, 1 5, 4 6, 1 2))', 4326)) > , ('poly2', geometry::STGeomFromText('POLYGON ((1 2, 1 3, 2 5, 4 6, 1 2))', 4326)) > , ('poly3', geometry::STGeomFromText('POLYGON ((7 9, 8 7, 9 6, 7 9))', 4326)) > > SELECT t1.n > , t2.n > FROM dbo.t t1 > INNER JOIN dbo.t t2 ON t1.i.STIntersects(t2.i) = 1 > WHERE > t1.n < t2.n; > GO > > <pre> > n | n > :---- | :---- > poly1 | poly2 > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=5f6a5eecbe2f38974680e3bc46df50c9)*
back to fiddle