Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
I have 2 tables
table a col name
table b col name
 
I have made the primary key of table a col name
and the foreign key = table b col na me and i set the relationship as cascade on update but i keep getiing this error
 
The UPDATE statement conflicted with the REFERENCE constraint "FK_T_b_T_a". The conflict occurred in database "test", table "b", column 'Name'. When I try to do the following update in table a
 
update a
Set name = 2
where name = 1
 
I want it to update b col name
 
Please any help would be appreciated
Posted 18-Sep-12 23:22pm
Comments
Andrei Straut at 19-Sep-12 5:38am
   
Maybe you should check your reference FK_T_b_T_a and see what it refers to. It may give you a hint as to what actually happens in there.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Since you haven't shown us how exactly the tables are defined, you may want to look at this here example that explains it pretty well, I'd say: SQL Server – How to cascade UPDATEs and DELETEs to related tables[^].
 
Hope this helps you!
 
To make your question clearer you should really add the DDL[^] statements that create the two tables.
 
BTW, a strange thing is that you're using numbers in a column called name. I'd have thought a column with such a name to be varchar, nvarchar or some other text based type.
 
Regards,
 
— Manfred
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 605
1 Sergey Alexandrovich Kryukov 305
2 BillWoodruff 259
3 PIEBALDconsult 220
4 CPallini 220


Advertise | Privacy | Mobile
Web02 | 2.8.141029.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100