Modifying a Foreign Key

Visual Database Tools

Visual Database Tools

Modifying a Foreign Key

Modify the foreign key side of a relationship if you want to change which columns are related to columns in the primary key table.

To modify a foreign key

  1. In your database diagram, right-click the relationship corresponding to the foreign key you want to modify, then choose Properties from the shortcut menu.

    -or-

    Open the Table Designer for the table containing the foreign key you want to modify, right-click in the Table Designer, and choose Properties from the shortcut menu.

  2. Choose the Relationships tab.

  3. Select the relationship from the Selected relationship list.

  4. In the Foreign key table column, expand the list in the first row.

  5. Select a different table column from the list. The foreign key column must match the data type and size of the primary key column, with these exceptions:
    • A char column or sysname column can relate to a varchar column.

    • A binary column can relate to a varbinary column.

    • A user-defined data type can relate to its base type.

Any changes you make to the relationship's properties take effect as soon as you move outside the grid in the property pages. The constraint is updated in the database when you save your table or diagram.

Note   Modifying a relationship in a database diagram marks both of the related tables as modified. Consequently, each table will also be marked as modified in any other diagrams in which it appears.

See Also

Constraints | Deleting a Foreign Key Constraint | Foreign Key Constraints | Modifying a Primary Key