If you change the data, replacing
, ('E3A22', geometry::STGeomFromText('LINESTRING(00 12, 07 12)', 0))
with
, ('E3A22', geometry::STGeomFromText('LINESTRING(06 12, 07 12)', 0))
so that A1B20 and D1B19 intersect,
D1B19 and E3A22 intersect
but A1B20 and E3A22 now do not intersect, the cursor and CTE solutions give different results.
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537