0 votes
1 view
in Azure by (32.3k points)

Is it possible to create a clustered index from a create table statement in SQL Server 2008 that is not a primary key?

The purpose of this is for a table in SQL Azure, so it is not an option for me to first create the table, and then create the clustered index on the table.

Edit: Apparently it was FluentMigrator that was causing my problems, it's version table does not have a clustered index so it was erroring trying to create the versioning table, not my table.

1 Answer

0 votes
by (16.8k points)

CREATE TABLE dbo.Table_1

    (

    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,

    SomeOtherUniqueColumn int NOT NULL CONSTRAINT Item4 UNIQUE CLUSTERED

)  ON [PRIMARY]

note the specification of nonclustered on the primary key

This will still work.

CREATE TABLE dbo.Table_1

    (

    SomeOtherUniqueColumn int NOT NULL CONSTRAINT Item4 UNIQUE CLUSTERED

)  ON [PRIMARY]

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...