Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Relationship Error

Author  Topic 

muzzettemm
Posting Yak Master

212 Posts

Posted - 2009-08-05 : 18:16:53
Hi guys Can you help me I added another table and tried to create a replationship with the People_tbl but its giving me an error

'People_tbl' table saved successfully
'Tanf_tbl' table
- Unable to create relationship 'FK_Tanf_tbl_People_tbl'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Tanf_tbl_People_tbl". The conflict occurred in database "SCAIR", table "dbo.People_tbl", column 'Parent ID'.

the thing is I ran the script you gave me and its not working for some reason



Alter Table [Tanf_tbl] with NOCHECK add constraint [FK_Tanf_tbl_People_tbl] foreign key ([Parent ID])

REFERENCES [People_tbl]([Parent ID])

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-08-05 : 19:09:23
Is there a foreign key defined on the People_tbl table that references the Tanf_tbl table?

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-08-05 : 20:54:42
There's already a Foreign key on that column. You can view it by opening up SSMS and then just Navigate to that db then expand the keys on the table.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page
   

- Advertisement -