Click here to Skip to main content
12,827,807 members (45,302 online)
Rate this:
Please Sign up or sign in to vote.
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 19-Sep-12 0:22am
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

Rate this: bad
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.


— Manfred

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
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