Cannot drop an index that is being used for PK constraint enforcement (MS SQL Server 2008)

No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.

I am trying to execute the following SQL command:

DROP INDEX pk_name_PK ON [dbo].[TableName];

I am getting the following error:

It is being used for PRIMARY KEY constraint enforcement.

Please help! Thanks!

1 Answer

Internet users could send Bitcoin Tips to you if they like your answer!

If you happen to notice the MSDN entry on DROP INDEX, you will see that this behavior is noted. In case you overlooked it, the relevant comment is this:

“The DROP INDEX statement does not apply to indexes created by defining PRIMARY KEY or UNIQUE constraints. To remove the constraint and corresponding index, use ALTER TABLE with the DROP CONSTRAINT clause.”

You sould run this code:

alter table [dbo].[TableName] drop constraint pk_name_PK

So, there you go.


Too many commands? Learning new syntax? is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with!

Post Answer