Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

INSERT statement conflicted with the FOREIGN KEY constraint. The statement has been terminated.

$
0
0

Hi all,

I get this error when inserting data...

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Participant_Log_BiometricInstance_Participant_Activities". The conflict occurred in database "ProvantCustomerPortal", table "dbo.Activities", column 'Id'.
The statement has been terminated.

My query looks like this 

insert into [dbo].[Participant_BiometricInstance](ParticipantId, ActivityId, ProviderTypeId, Fasting, ExternalSystemId, ResultsDate, ModifiedBy, ModifiedDate)
select participantID,'','','',NULL,getdate(),NULL,getdate() from [dbo].[Participant_Profile]
union all 
select '',id,'','','','','','' from [dbo].[Activities]
union all
select '','',id,'','','','','' from [dbo].[Log_ProviderType]

ParticipantID, ActivityId, ProviderTypeId are Foreign Keys.

Id is primary key in Activity table

Id is primary key in Log_ProviderType.

Does anyone know how can we solve this?



Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>