FOREIGN KEY SAME TABLE error - but foreign key doesn't exist

前端 未结 1 1428
故里飘歌
故里飘歌 2020-12-21 19:34

I am trying to add a foreign key constraint which references the same table.

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N\'[db         


        
相关标签:
1条回答
  • 2020-12-21 19:55

    If the table already has data, all values in the column documents_parent should be present in the column id, otherwise you will get an error.

    You can use WITH NOCHECK, if we want to allow it

    http://technet.microsoft.com/en-us/library/ms177463(v=sql.105).aspx

    0 讨论(0)
提交回复
热议问题