Search code examples
indexingazure-sql-databaseclustered-index

How can I recluster a table hosted in SQL Azure


Normally in SQL Server, running the following would be fine:

ALTER TABLE dbo.ChangeLog DROP CONSTRAINT PK_ChangeLog

ALTER TABLE dbo.ChangeLog ADD CONSTRAINT PK_ChangeLog PRIMARY KEY NONCLUSTERED (ChangeLogID)

CREATE CLUSTERED INDEX IX_ChangeLog_FTRequestID ON dbo.ChangeLog (FTRequestID);

However, when trying to run it against a database hosted by Azure, I get the following error:

Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.

Obviously, if I try to create a second clustered index first, I get this error instead:

Cannot create more than one clustered index on table 'dbo.ChangeLog'. Drop the existing clustered index 'PK_ChangeLog' before creating another

This seems to be a catch 22.

Is there any way I can get around this without dropping and recreating the entire table?


Solution

  • Heaps are not supported on the current version of SQL Database. Please upgrade your SQL Database server to SQL Database Update V12.