If you have defined the Foreign Key constraints as ON UPDATE CASCADE
then the Primary Key value that was changed should cascade down to all the Foreign Keys with that constraint.
If you do not have the ON UPDATE CASCADE
constraint, then you will need create scripts to complete the update.
EDIT: Since you do not have the ON UPDATE CASCADE
constraint, but you want to have that set up, it is a bit of work. SQL Server does not support altering the constraints to a new setting.
It is necessary to iterate through each table that has a FK constraint to the PK table. For each table with the FK:
- ALTER TABLE to drop the existing FK constraint.
- ALTER TABLE again to create the ON UPDATE CASCADE constraint for the FK in question.
This takes a bit of effort, but would result in your constraint being properly set for your case.
EDIT 2: The information that you need is found in sys.foreign_keys. You can select from that table to get all the information you need.
A post from John Paul Cook can be found here:
This code will drop and create ALL FK constraints in a database. You should be able to work from that to make only the changes that you want in your database.