I have a table with a primary key that I would like to add another column to. The problem is, when I add this, Sql Server drops all foreign key references to that table.
Is there any way to fix this? (or maybe even a tool that refactors this)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s nothing to “fix” – you are changing the PK, so the FKs need to be dropped.
What do you think should happen if you add a field to the PK – all FK references get the field added as well? What if that extra field doesn’t exist in your other tables? They have to be dropped and then recreated to make sure they are even valid references.