How to check existing data when creating a relationship in SQL server

When Developers working with SQL Server “Denali”, MS SQL Server 2008 R2 and MS SQL Server 2005 want to check existing data when they are creating relationship, they should follow the next steps:

1. In Object Explorer, right-click the table that will be on the foreign-key side of the relationship and click Design (Modify in SP1 or earlier).

The table opens in Table Designer.

2. From the Table Designer menu, click Relationships.

3. In the Foreign-key Relationships dialog box, click Add.

The relationship appears in the Selected Relationship list with a system-provided name in the format FK_<tablename>_<tablename>, where tablename is the name of the foreign key table.

4. In the Foreign Key Relationships dialog box, select the relationship from the Selected Relationship list.

5. In the grid, click Check Existing Data On Creation.

6. Choose Yes from the drop-down list to the right of the property.

The foreign key constraint is applied when Developers save the table. If any constraint violations are encountered during the save process, the table cannot be saved.