SQL server display two different spatial columns at once

1.7k views Asked by At

I have two tables with a Geometry column each, one for different Districts and another one for Bank Agencies. Im trying to display both spatial columns at once so i can see where in the district each of the bank agencies are. Is this possible with the Geometry type? Right now, I can see them in the Spatial Results tab but as two distinct columns, im trying to overlap them.

Im using SQL Server 2008 btw.

query example:

select a.Geometria, a.nombre, d.GeometriaD
from dbo.AgenciaBancaria a join dbo.Distrito d on a.idDistrito = d.ID
where d.Nombre = 'Carmen'
1

There are 1 answers

1
stakx - no longer contributing On BEST ANSWER

AFAIK, SQL Server Management Studio's Spatial Results tab can only display one spatial column at any time.

If you want to overlap geometries from two columns, you might have to create their union or intersection in your query, and then display that; for example:

SELECT a.Geometria.STIntersection(d.GeometriaD) AS Intersection
FROM dbo.AgenciaBancaria a 
JOIN dbo.Distrito d ON a.idDistrito = d.ID
WHERE d.Nombre = 'Carmen'

-- The above query is just for demonstration purposes; it would possibly need some 
-- optimization to run faster, such as a fast intersection test in the WHERE clause.

Or a graphical example of displaying the results of STIntersection and STUnion:

Results of <code>STIntersection</code> and <code>STUnion</code>