Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Created March 28, 2013 09:10
Show Gist options
  • Save davidfowl/5261815 to your computer and use it in GitHub Desktop.
Save davidfowl/5261815 to your computer and use it in GitHub Desktop.
begin transaction
go
alter table dbo.ChatMessages drop constraint PK_ChatMessages
go
create clustered index CX_ChatMessages_When on dbo.ChatMessages ([When])
go
alter table dbo.ChatMessages add constraint PK_ChatMessages primary key nonclustered ([Key])
go
commit transaction
go
@yeurch
Copy link

yeurch commented Mar 28, 2013

As you can only have one clustered index on a table, yes, you must drop the PK first and recreate it as a non-clustered PK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment