The two tables are related to each other due to the FK constraint. I am trying to update these tables by disabling ALL Trigger, but still getting the following error: -
The UPDATE operation contradicted the FOREIGN KEY constraint "FK_TEST_REFERRING_REFPHYSI". The conflict occurred in the database "ccdb", in the table "dbo.RefPhysician", in the column "RefID". Application completed.
This is how I try to complete my task. Please help or update the following T-SQL: -
Begin Transaction Begin Try ALTER TABLE Test DISABLE Trigger ALL ALTER TABLE RefPhysician DISABLE Trigger ALL UPDATE Test SET RefID = '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45' WHERE RefID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45'; UPDATE RefPhysician SET RefID = '05f6c6b4-63ff-45b2-a5e2-920d5dce3e45' , SpecID = NULL , RefLastName = '117002 DR. BRAD DIBBLE' , RefFirstName = '201-190 CUNDLES RD E, BARRIE ONT L4M 4S5' , RefMiddleName = NULL , RefPhone1 = '6138365083' , RefPhone2 = 'print,read,866,1' , RefFax = '6476476464' , RefEmail = ' Dibble@hotmail.ca ' WHERE RefID = '05e6c6b4-63ff-45b2-a5e2-920d5dce3e45' ALTER TABLE Test ENABLE Trigger ALL ALTER TABLE RefPhysician ENABLE Trigger ALL Commit Transaction End Try Begin Catch Rollback Transaction End Catch
Jango source share