+ 1

why this error happens?? Error: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Reviewtasks_Reviewers".

CREATE TABLE [dbo].[Reviewers] ( [reviewersID] INT IDENTITY (1, 1) NOT NULL, [workload] INT NULL, [userID] INT NULL, PRIMARY KEY CLUSTERED ([reviewersID] ASC), CONSTRAINT [FK_Reviewers_Users] FOREIGN KEY ([userID]) REFERENCES [dbo].[Users] ([userid]) ); CREATE TABLE [dbo].[Reviewtasks] ( [reviewtasksID] INT IDENTITY (1, 1) NOT NULL, [reviewersID] INT NOT NULL, [wID] INT NOT NULL, [reviewstatus] NVARCHAR (50) NOT NULL, [score] INT NULL, PRIMARY KEY CLUSTERED ([reviewtasksID] ASC), CONSTRAINT [FK_Reviewtasks_DocumentWork] FOREIGN KEY ([wID]) REFERENCES [dbo].[DocumentWork] ([wID]), CONSTRAINT [FK_Reviewtasks_Reviewers] FOREIGN KEY ([reviewersID]) REFERENCES [dbo].[Reviewers] ([reviewersID]) );

18th Jul 2020, 2:58 AM
Beast
Beast - avatar
9 odpowiedzi
+ 2
Beast Can you show the INSERT query here? As I see from the 'Reviewtasks' structure, the two tables were linked by 'reviewersID' column. So please make sure that the value for that column (in the INSERT query) is available in 'Reviewers' table.
18th Jul 2020, 3:59 AM
Ipang
+ 2
Is the problem solved now? Beast
18th Jul 2020, 7:59 AM
Ipang
+ 1
Beast What do you mean? I don't understand ...
18th Jul 2020, 6:46 AM
Ipang
+ 1
Beast I was asking you to share the INSERT query that is causing the error. Can you paste the query in your thread Description so people can see what was wrong? From my understanding the error was *possibly* triggered by an attempt to insert data into 'Reviewtasks' table, but the process failed because one or more data to be inserted is against a restriction applied by a referential connection between table 'Reviewers' and 'Reviewtasks'.
18th Jul 2020, 7:18 AM
Ipang
+ 1
I got it Ipang thanks
18th Jul 2020, 7:33 AM
Beast
Beast - avatar
+ 1
Thanks Ipang
18th Jul 2020, 7:34 AM
Beast
Beast - avatar
0
How can I find INSERT query please??
18th Jul 2020, 6:13 AM
Beast
Beast - avatar
0
You said that can I show the INSERT query??
18th Jul 2020, 6:49 AM
Beast
Beast - avatar
0
But I don't know how to find INSERT query
18th Jul 2020, 6:49 AM
Beast
Beast - avatar