根據sqlserver geometry數據定義獲取空間類型邊界範圍sql
--獲取指定街道邊界的xy最大最小值 declare @point_cnt int,@i int,@point geometry,@jdcode nvarchar(50) set @jdcode='440307006'--街道編碼 create table #temp_point(id int identity,x float,y float) select @point_cnt =geom.STNumPoints() from [dbo].[jd] where jdcode=@jdcode set @i=1 while @i<=@point_cnt begin select @point = geom.STPointN(@i) from [dbo].[jd] where jdcode=@jdcode insert into #temp_point(x,y) values(@point.STX,@point.STY) set @i = @i+1 end select min(x) as minx,min(y) as miny,max(x) as maxx,max(y) as maxy from #temp_point truncate table #temp_point; drop table #temp_point