Sunday 12 June 2016

Error: Msg 3723, It is being used for PRIMARY KEY constraint enforcement.

When we execute following query to sql management query windows:

DROP INDEX tblEmployees.PK__Table__3214EC079D3D6FE5

When you execute it we will get following msg 3723

will get:
--Msg 3723, Level 16, State 4, Line 1
--An explicit DROP INDEX is not allowed on index 'Table.PK__Table__3214EC079D3D6FE5'.
--It is being used for PRIMARY KEY constraint enforcement.

This error message will get when you are going to drop a clustered index on table using query window.
So it stated that you need to drop primary key constraint of the table. And we know that table has only one clustered index so you can create only one clustered index in the table but you can add more columns to the clustered index.

How to solve this error:
You can write following query to the query window and select

ALTER TABLE [Table]
DROP CONSTRAINT PK__Table__3214EC079D3D6FE5

Now if you will refresh the index folder of table you should see the primary key clustered index removed from it.
You can also remove using graphically for that one you need to expand the table and go to table and expand index folder where you can see primary key clustered index with PK_ prefix right click on it and press on delete. It will delete pk index.

No comments:

Post a Comment