# Sql-server – SQL Server 2012 duplicate key error with Spatial index that shouldn’t be unique

indexspatialsql-server-2012

We have a table that has a geometry column that is filled by a stored procedure from two x and y values whenever they're changed

( SW_GEOMETRY = GEOMETRY::STGeomFromText('POINT('+ CONVERT(VARCHAR(50),@xval) + ' ' + CONVERT(VARCHAR(50),@yval) +')',27700) )


The table has a spatial index (SPIX_BLPUS) on it on the SW_GEOMETRY column.

For some specific value changes of, for example, a y value, we get the error:

Cannot insert duplicate key row in object
'sys.extended_index_462728801_384000' with unique index 'SPIX_BLPUS'.
The duplicate key value is (0x0119251c04, 10033223837).

I don't understand why this is happening, as the index shouldn't care about uniqueness? It doesn't happen for all value changes, just specific ones that I can only assume already exist in the index – but duplicates should be allowed.