• 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 http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/