locked
Foriegn Key Problems RRS feed

  • Question

  •  

    There is one difference in a table that I have in my Staging Environment to my Production environment....

     

    ALTER TABLE [dbo].[OPS_TimeCards] ADD CONSTRAINT [FK_OPS_TimeCards_OPS_Employees] FOREIGN KEY ([EmployeeID]) REFERENCES [dbo].[OPS_Employees] ([EmployeeID])

    GO

     

     

    I just want to add this FK to my table but i get this error....but I am not sure why, cause this FK does not exsist on the table..i click on the table and choose modify go to relateshonships and its not there.....any help???

     

     

    Msg 547, Level 16, State 0, Line 1

    The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_OPS_TimeCards_OPS_Employees". The conflict occurred in database "BridgeFinance", table "dbo.OPS_Employees", column 'EmployeeID'.

    Tuesday, September 16, 2008 4:53 PM

Answers

  • This is probably caused due to a data conflict.  You should check to see if you have an id in the reference table that does not exist in the primary.

     

    Tuesday, September 16, 2008 5:02 PM

All replies

  • This is probably caused due to a data conflict.  You should check to see if you have an id in the reference table that does not exist in the primary.

     

    Tuesday, September 16, 2008 5:02 PM
  •  

    U were exactly right.  Thanks!
    Tuesday, September 16, 2008 5:11 PM