March 22, 2010 at 12:43 pm
I'm trying to drop the clustered index on a table, but it's giving me the below error.
An explicit DROP INDEX is not allowed on index 'dbo.PAYMENTS_tmp.PK_Payments_tmp'. It is being used for PRIMARY KEY constraint enforcement.
Can anyone please tell me why am i not allowed to drop it and how can i drop it?
Thanks.
March 22, 2010 at 12:45 pm
sunny.tjk (3/22/2010)
I'm trying to drop the clustered index on a table, but it's giving me the below error.An explicit DROP INDEX is not allowed on index 'dbo.PAYMENTS_tmp.PK_Payments_tmp'. It is being used for PRIMARY KEY constraint enforcement.
Can anyone please tell me why am i not allowed to drop it and how can i drop it?
Thanks.
You would have to remove the primary key first. And prior to that, if the key is used in any relationships (FK to another table), then you will need to remove those as well.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 22, 2010 at 1:10 pm
I deleted the foreign key but I'm still not able to delete the primary key. Is it any way connected to the unique keys that I've on 3 columns?
March 22, 2010 at 1:13 pm
sunny.tjk (3/22/2010)
I deleted the foreign key but I'm still not able to delete the primary key. Is it any way connected to the unique keys that I've on 3 columns?
A Primary Key is a Unique key. Have you created an additional UK on those columns?
When trying to drop your PK, what message are you getting?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 22, 2010 at 1:14 pm
If it is really a primary key, then you would not use the DROP INDEX statement.
You would use ALTER TABLE tablename DROP CONSTRAINT constraint_name
March 22, 2010 at 1:17 pm
Michael Valentine Jones (3/22/2010)
If it is really a primary key, then you would not use the DROP INDEX statement.You would use
ALTER TABLE tablename DROP CONSTRAINT constraint_name
Good idea to point it out so clearly.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 22, 2010 at 1:37 pm
Great!! The ALTER statement worked. i always thought that I could right click on the index and then delete it from Management studio.
I'll remember this.
Thanks a lot everyone.
March 22, 2010 at 1:55 pm
You're welcome.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply