Reputation: 7062
I have a clustered index on a table indexing on the text
column. I want to switch that column with a different column like ID
, how do I alter the index?
I can't drop and recreate because this is running on Azure and the table needs to have clustered index all the time.
The SQL command and the syntax for changing index columns in an index.
alter index ?
Upvotes: 10
Views: 21195
Reputation: 32737
Try this:
create clustered index [your_index_name]
on [your_table]
([ID])
with (drop_existing = on)
Upvotes: 18
Reputation: 755381
You cannot alter a clustered index.
The only option is to drop it and re-create it with the new column.
In your case, you'll probably have to re-create the table with the new clustered index on ID
and then copy the data over.
Upvotes: 7