locked
index on Geography Field RRS feed

  • Question

  • CREATE SPATIAL INDEX [geo]
      ON Venues (geo)

    but it says I don't have a clustered Prim Key as required
    but then..

    ALTER TABLE venues
    ADD CONSTRAINT id PRIMARY KEY(id)

    says:
    Cannot define PRIMARY KEY constraint on nullable column in table 'venues'.

    Now ID is a numeric and there are no dups and none empty but I am guessing
    that null would be allowed due to some "typing" of the feild that is default



    - 10spotdomain for all your domain and domain related needs
    Tuesday, August 2, 2011 6:52 PM

Answers

  • Solution for creating Geo index on my table Venues

    first you have to disallow nulls
    then create a primary key in this case it's a simple ID number
    then SQL Server will allow you to create the index on your Geography field.

     

    ALTER TABLE [Venues] ALTER COLUMN [ID] INTEGER NOT NULL

    ALTER TABLE venues
    ADD CONSTRAINT id PRIMARY KEY(id)

    CREATE SPATIAL INDEX [geo]
       ON Venues (geo)

     

     


    - 10spotdomain for all your domain and domain related needs
    • Marked as answer by Mothermugger' Tuesday, August 2, 2011 7:03 PM
    Tuesday, August 2, 2011 7:03 PM