SQL Server 2005
Having problems dropping/recreating a Foreign Key:
When I do this:
ALTER TABLE customerNPaccount
DROP CONSTRAINT FK_CustomerNPAccount_CUSTOMER
It results in:
Msg 3728, Level 16, State 1, Line 1
'FK_CustomerNPAccount_CUSTOMER' is not a constraint.
Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.
OK - but when I try to add it:
ALTER TABLE customerNPaccount
ADD CONSTRAINT FK_CustomerNPAccount_CUSTOMER FOREIGN KEY (customerNo) REFERENCES customer(customerNo)
Results in:
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_CustomerNPAccount_CUSTOMER". The conflict occurred in database "myDatabase", table "dbo.CUSTOMER", column 'CUSTOMERNO'.
So, does or does not this Foreign Key exist???
Am trying to find a system table or sp that will will ALL FOREIGN KEYS for a given database... is this possible?
sp_help does not yield any clues.
THANKS
Having problems dropping/recreating a Foreign Key:
When I do this:
ALTER TABLE customerNPaccount
DROP CONSTRAINT FK_CustomerNPAccount_CUSTOMER
It results in:
Msg 3728, Level 16, State 1, Line 1
'FK_CustomerNPAccount_CUSTOMER' is not a constraint.
Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.
OK - but when I try to add it:
ALTER TABLE customerNPaccount
ADD CONSTRAINT FK_CustomerNPAccount_CUSTOMER FOREIGN KEY (customerNo) REFERENCES customer(customerNo)
Results in:
Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_CustomerNPAccount_CUSTOMER". The conflict occurred in database "myDatabase", table "dbo.CUSTOMER", column 'CUSTOMERNO'.
So, does or does not this Foreign Key exist???
Am trying to find a system table or sp that will will ALL FOREIGN KEYS for a given database... is this possible?
sp_help does not yield any clues.
THANKS