I'm using sql server 2008 R2, and I have two tables, Regions and Facilities. Both have a column containing a geography element.
I want to calculate the union on the intersection of the geograpy elements, like this:
SELECT * from Regions join Facilities on [Regions].[geography].STIntersects([Facilities].[geography])
which of course doesn't work. The regions are large polygons, and the facilities are points each of which is contained in only one polygon.
I can write some kind of (pseudocode)
for each r in Regions:
for each f in Facilities:
if f.[geography].STIntersects(r.[geography]):
print r, f
but the whole point of using a database is to operate on the set not the elements, surely?
So, is there a better way to do this?
thanks Melanie