SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The INSERT statement conflicted with the FOREIGN KEY constraint(Not reproducible)


The INSERT statement conflicted with the FOREIGN KEY constraint(Not reproducible)

Author
Message
neethu payal
neethu payal
SSC-Enthusiastic
SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)SSC-Enthusiastic (111 reputation)

Group: General Forum Members
Points: 111 Visits: 94
hello sir..can u plz help me .....i don't knw how to solve this conflict ''The INSERT statement conflicted with the FOREIGN KEY constraint "FK_product_details". The conflict occurred in database "catalog", table "dbo.product_details", column 'product_id' ".......
i have 2 tables, product_details and purchase_details.....

CREATE TABLE product_details
(
product_id int identity(1,1) not null,
product_name varchar(500),
product_catagory varchar(100),
CONSTRAINT PK_product_details PRIMARY KEY(product_id)
)

CREATE TABLE purchase_details
(
Purchase_id int not null identity(1,1) ,
product_id int CONSTRAINT FK_product_details FOREIGN KEY REFERENCES product_details(product_id) ,
Product_Name varchar(500),
Product_Cost VARCHAR(500),
Product_Quantity varchar(500),
CONSTRAINT PK_Purchase_details PRIMARY KEY(Purchase_id)
)

when i was try to insert values in 'purchase_details' that error msg displayed.......i dont know wats the mistak there....
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27322 Visits: 17557
nitha jen (4/1/2013)
hello sir..can u plz help me .....i don't knw how to solve this conflict ''The INSERT statement conflicted with the FOREIGN KEY constraint "FK_product_details". The conflict occurred in database "catalog", table "dbo.product_details", column 'product_id' ".......
i have 2 tables, product_details and purchase_details.....

CREATE TABLE product_details
(
product_id int identity(1,1) not null,
product_name varchar(500),
product_catagory varchar(100),
CONSTRAINT PK_product_details PRIMARY KEY(product_id)
)

CREATE TABLE purchase_details
(
Purchase_id int not null identity(1,1) ,
product_id int CONSTRAINT FK_product_details FOREIGN KEY REFERENCES product_details(product_id) ,
Product_Name varchar(500),
Product_Cost VARCHAR(500),
Product_Quantity varchar(500),
CONSTRAINT PK_Purchase_details PRIMARY KEY(Purchase_id)
)

when i was try to insert values in 'purchase_details' that error msg displayed.......i dont know wats the mistak there....


You really should start your own thread instead of jumping onto somebody else's. However, the issue here is you are trying to insert a row into purchase_details and the value in product_id does not exist in your product_details table.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search