I am a new in this field and need help, how to code using SQL spatial a function that retrieve loops in a network.The input, flag: Geography and barrier: Geography and two spatial tables, first one will list the edges(edgekey, from_junction, to_junction, polyline) and the second table containing juctions(junctionkey, point).
The output will be a spatial table containing (edgekey, polykey, from_junction, to_junction, polyline), a single polygon will have the same polykey for each from_junction to_junction value.