INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server

0 votes

I am getting the following error. Could you please help me?

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Sup_Item_Sup_Item_Cat". The conflict occurred in database "dev_bo", table "dbo.Sup_Item_Cat". The statement has been terminated.

Code:

insert into sup_item (supplier_id, sup_item_id, name, sup_item_cat_id, 
                      status_code, last_modified_user_id, last_modified_timestamp, client_id)   
values (10162425, 10, 'jaiso', '123123',
        'a', '12', '2010-12-12', '1062425')

The problem is being caused by the final column, client id. I made an effort to insert an existing value into the dbo. No fun after entering Sup Item Cat into the column that corresponds to Sup Item.

 Can someone please help me with this?

Sep 18, 2022 in Database by Kithuzzz
• 38,010 points
7,389 views

1 answer to this question.

0 votes
Your table dbo.Sup Item Cat refers to another table via a foreign key. A FK cannot have a value in that column that is not also in the primary key column of the database being referred, according to how it functions.

Open SQL Server Management Studio and type sp help 'dbo.Sup Item Cat' if you have it. Look at the column that FK is on and the column of the table that it refers to. Bad data is being inserted by you.
answered Sep 19, 2022 by narikkadan
• 63,420 points

Related Questions In Database

0 votes
0 answers

How to remove foreign key constraint in sql server?

In order to enter values of my ...READ MORE

Aug 21, 2022 in Database by Kithuzzz
• 38,010 points
722 views
0 votes
1 answer

What is the candidate key in SQL Server?

A Candidate Key is any column or ...READ MORE

answered Feb 23, 2022 in Database by Neha
• 9,060 points
3,795 views
0 votes
0 answers

Get the last inserted row ID (with SQL statement)

When you add a new record to ...READ MORE

Aug 20, 2022 in Database by Kithuzzz
• 38,010 points
1,450 views
0 votes
1 answer

SQL Server CASE .. WHEN .. IN statement

Two forms of CASE statements are getting ...READ MORE

answered Feb 8, 2022 in Database by Vaani
• 7,020 points
510 views
0 votes
0 answers

Selecting COUNT(*) with DISTINCT

In SQL Server 2005, I have a ...READ MORE

Feb 14, 2022 in Database by Neha
• 9,060 points
314 views
0 votes
1 answer

SQL Server CASE .. WHEN .. IN statement

Try this... SELECT AlarmEventTransactionTableTable.TxnID, ...READ MORE

answered Jun 14, 2022 in Others by polo
• 1,480 points
353 views
0 votes
0 answers

Simple DateTime sql query

How do I query the DateTime database ...READ MORE

Aug 12, 2022 in Database by Kithuzzz
• 38,010 points
430 views
0 votes
1 answer

SQL Server WITH statement

I'm going to guess because I don't ...READ MORE

answered Sep 10, 2022 in Database by narikkadan
• 63,420 points
442 views
0 votes
1 answer

Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) in sql 2008

Solution Go to Start > Programs > Microsoft SQL Server > Enterprise Manager. Right-click the SQL ...READ MORE

answered Sep 12, 2022 in Database by narikkadan
• 63,420 points
865 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP