1. 程式人生 > >sqlserver 空間查詢提高效率

sqlserver 空間查詢提高效率

declare @CityRiver table(geo geometry,riverId int)
insert into   @CityRiver  select Geo,riverId  from 
( select  pr.Shape.STIntersection(ct.Shape) as Geo,cr.OBJECTID as riverId
from Ageo_City ct,Ageo_CityRiver cr,Ageo_ProRiverRange pr
where  1 = 1
and pr.Shape.STIntersects(ct.Shape)=1
and pr.ProRiver = 38
and cr.City = ct.OBJECTID 
and cr.ProvinceRiver = 38 ) as a

select * from @CityRiver cr,Ageo_rainStation rs
where 1 = 1
and cr.geo.STContains(rs.shape) = 1