I have a table on azure sql database (hosted instance). I am trying to set a spatial index to a geography column.
Query:
=================================== Index query ===================================
CREATE SPATIAL INDEX sp_idx ON Routes(Route_st_way_end) USING GEOGRAPHY_GRID WITH (GRIDS = (LEVEL_1 = LOW, LEVEL_2 = LOW, LEVEL_3 = HIGH, LEVEL_4 = HIGH), CELLS_PER_OBJECT = 16, DROP_EXISTING = ON)
Error :
Msg 12009, Level 16, State 2, Line 1
Could not find the spatial index 'sp_idx' on table 'Routes'. Either no spatial index with this name exists, or a non-spatial index might be using the same name. Fix the index name, avoiding duplicates. If a relational index has the same name, drop the regular relational index.
Create Table Script :
=================================== Table Script ===================================
CREATE TABLE [dbo].[Routes] (
[route_id] INT IDENTITY (1, 1) NOT NULL,
[driverPostsTrip_id] INT NOT NULL,
[Route_st_way_end] [sys].[geography] NOT NULL,
[TotalDuration] FLOAT (53) NOT NULL,
[TotalDistance] FLOAT (53) NOT NULL,
[TripDeparture_DateTime] DATETIME NOT NULL,
[TripArrival_DateTime] DATETIME NOT NULL,
PRIMARY KEY CLUSTERED ([route_id] ASC),
FOREIGN KEY ([driverPostsTrip_id]) REFERENCES [dbo].[DriverPostsTrip] ([driverPostsTrip_id])
);
I don't understand why is it erroring out.
Note: I am using Azure data studio on Mac (I don't have a way to use SSMS).
Please check the attached screenshot for details around the error and table design.