Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Can't drop primary key? Expand / Collapse
Author
Message
Posted Tuesday, July 31, 2012 5:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 13, 2015 1:37 AM
Points: 9, Visits: 21
Hi
I'm struggling to drop a primary key.
I get the error:
An explicit DROP INDEX is not allowed on index 'MyTable.PrimaryKey'. It is being used for FOREIGN KEY constraint enforcement.

"sp_helpindex MyTable", returns 1 entry:
PrimaryKey, nonclustered, unique located on PRIMARY, ID

I also tried:
alter table MyTable DROP CONSTRAINT PrimaryKey

I even went as far as dropping all primary keys and foreign keys on the entire database, but the error still pops up. Any ideas?
Post #1337816
Posted Tuesday, July 31, 2012 5:59 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 12:50 PM
Points: 14,221, Visits: 37,161
what results do you get when you run EXEC sp_fkeys myTable?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1337818
Posted Tuesday, July 31, 2012 8:38 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 13, 2015 1:37 AM
Points: 9, Visits: 21
OK - thanks. I found a couple of FK's, and I've removed it manually and it's working now.
Post #1337947
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse