Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. --sample assumes two tables - reference.Townland and bioenergy.soils
  2. --create a sample area by buffering a point
  3. DECLARE @g AS geometry;
  4. SET @g = geometry::STGeomFromText('POINT (200000 200000)', 29902).STBuffer(1000);
  5.  
  6. --create a temporary table variable to store results
  7. DECLARE @results TABLE (GEOM Geometry);
  8.  
  9. --select all the polygons in our sample area and add them to the same table
  10. INSERT INTO @results
  11. SELECT GEOM29902
  12. FROM reference.Townland
  13. WHERE GEOM29902.STIntersects(@g) = 1
  14.  
  15. --select all the points in our sample area and add them to the table
  16. --in this case the centroids of a second polygon dataset are used
  17. INSERT INTO @results
  18. SELECT GEOM29902.STCentroid()
  19. FROM bioenergy.soils
  20. WHERE GEOM29902.STIntersects(@g) = 1
  21.  
  22. --select all the results in our temporary table
  23. SELECT GEOM
  24. FROM @results
Add Comment
Please, Sign In to add comment