Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

SQL
update a
Set name = 2
where name = 1


I want it to update b col name

Please any help would be appreciated
Posted
Comments
Andrei Straut 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

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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900