将变量传递到空间索引中

时间:2014-09-17 15:54:18

标签: sql sql-server spatial-index

我有以下代码,允许我定义空间数据库的边界框:

with TEMP as(
select 
MIN(geometry.STEnvelope().STPointN(1).STX) as X1
,MIN(geometry.STEnvelope().STPointN(1).STY) as Y1 
,MAX(geometry.STEnvelope().STPointN(3).STX) as X2 
,MAX(geometry.STEnvelope().STPointN(3).STY) as Y2 
from ANCWOODLAND_SRID)

我希望能够做的是获取这些值并在创建空间索引脚本中使用它们,如下所示:

CREATE SPATIAL INDEX [spat_ANCWOODLAND_SRID] ON [dbo].[ANCWOODLAND_SRID] 
(
[GEOMETRY]
)USING  GEOMETRY_GRID 
WITH (
BOUNDING_BOX =(X1,Y1,X2,Y2), GRIDS =(LEVEL_1 = HIGH,LEVEL_2 = HIGH,LEVEL_3 = HIGH,LEVEL_4 = HIGH), 
CELLS_PER_OBJECT = 128, PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF,
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

但我不知道该怎么做,我们将非常感谢任何帮助。

提前致谢

0 个答案:

没有答案