• More for you Paul....

    The script I built was just so I can conceptually show you a simple example with your names. Run this script against a test blank test database.

    It creates 2 tables, with one column each (ParcelID), and populates them with some ids to recreate your problem.

    I need to create a unique index on Field_Data prior to attempting to create the constraint.

    First time fails with your error.

    Begin Tran and Rollback are blocks that execute the code and then undo everything once it has completed... so I can show that firstly... deleting the invalid records from GIS_Data allows for the creation of the constraint, and secondly inserting the missing ParcelIDs into Field_Data will also allow it.

    Further more you could:

    UPDATE GIS_Data set ParcelID = NULL where ParcelID NOT IN (SELECT ParcelID from Field_Data)

    ALTER TABLE GIS_Data

    ADD CONSTRAINT FK_FIELD_DATA FOREIGN KEY (ParcelID)

    REFERENCES Field_Data (ParcelID)

    This updates the records in GIS_Data with an invalid ParcelID to NULL. This is perfectly acceptable, but may not be logical, and the foriegn key will be create.

    Todd Carrier
    MCITP - Database Administrator (SQL 2008)
    MCSE: Data Platform (SQL 2012)