SQL Server 2008: The columns in table do not match an existing primary key or unique constraint

前端 未结 11 1128
梦谈多话
梦谈多话 2020-12-28 11:50

I need to make some changes to a SQL Server 2008 database.

This requires the creation of a new table, and inserting a foreign key in the new table that references t

11条回答
  •  一生所求
    2020-12-28 12:08

    I've had this situation that led me to this topic. Same error but another cause. Maybe it will help someone.

    Table1
    ColA (PK)
    ColB (PK)
    ColC
    
    
    Table2
    ID (PK)
    ColA
    COLB
    

    When trying to create foreign key in Table2 I've choose values from combobox in reverse order

    Table1.ColB = Table2.ColB
    Table1.ColA = Table2.ColA
    

    This was throwing me an error like in topic name. Creating FK keeping order of columns in Primary key table as they are, made error disappear.

    Stupid, but.. :)

提交回复
热议问题