0

I used the following code to create geography column using latitude, longitude

alter table [locate].[dbo].[BFLGeocodedResult] add geographyColumn as geography::STGeomFromText
('POINT('+convert(varchar(20),[Final Longitude])+' '+convert(varchar(20),[Final Latitude])+')',4326)

Also created Clustered Index and then tried to create spatial index using the below query

       CREATE SPATIAL INDEX [BFLGeocodedResult_sidx] ON [locate].[dbo].[BFLGeocodedResult]
(
    geographyColumn
)USING  GEOGRAPHY_GRID 
WITH (
BOUNDING_BOX =(-90, -180, 90, 180))

when I run the above query I get the error

Cannot create primary xml, selective xml or spatial index 'BFLGeocodedResult_sidx' on table 'locate.dbo.BFLGeocodedResult', column 'geographyColumn', because the column is computed.
1
  • Please edit your question to specify the exact version of SQL Server in use.
    – Vince
    Commented Jan 18, 2017 at 12:04

1 Answer 1

1

You create a computed column in your alter table statement. Consider creating a geography column and then update (populate) the column with your [Final Longitude] and [Final Latitude] data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.