I have the following code that allows me to define the bounding box of a spatial database:
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)
What I'd like to be able to do, is take these values and use them in a create spatial index script, like the one below:
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
But I don't know how to do this, any help would be greatly appreciated.
Thanks in advance