Skip to main content
Question

How to create a clustered primary key?

  • September 8, 2025
  • 1 reply
  • 29 views

tb09114
Supporter
Forum|alt.badge.img+27

I need to write my data into an MSSpatial database with a spatial index. However, when setting the SQLSERVER writer to the following then I do not get any spatial index generated.
 

When I now go into SSMS to ‘clean up’ after FME Form then I face the issue that I have a column id of type identity, but it isn’t a PrimaryKey. Looking into the possibilities to set an index in the attribute definitions I can see that I set the index to ClusteredNotNull. I can also see there is no possibility to generate a ClusteredPrimaryKey, as it is necessary to create the spatial index.
 


I assume I am going somewhere wrong here and would like to hear how I get my spatial index generated and applied when I am writing the data, instead of following up in SQL.

1 reply

virtualcitymatt
Celebrity
Forum|alt.badge.img+47

From my two seconds of reading it seems like SQLServer wiil created a ClusteredIndex on the Primary Key unless you tell it not to (https://learn.microsoft.com/en-us/sql/relational-databases/indexes/create-clustered-indexes?view=sql-server-ver17)

My guess would be that if you specify the PrimaryKey type at the bottom then you’ll end up with a Primary Key with a clustered index.

I’ve not worked with SQL Server before so I’m just a second pair of eyes here.