locked
foreign key RRS feed

  • Question

  • hi,

    i am getting this error

    Msg 547, Level 16, State 0, Line 2

    The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Person_Ad__Perso__540C7B00". The conflict occurred in database "Main", table "dbo.Person_M", column 'PID'.

    The statement has been terminated.

    i am inserting same values as the priamry key has,but still gettign this error

    also  i am not finding "FK__Person_Ad__Perso__540C7B00" ,under constraint tab

    please help me


    Friday, November 30, 2012 3:41 PM

Answers

  • I see two issues ;

    1. The Foreign Key constraint DOES NOT show up under the Constraint Folder in SSMS Object explorer, it will show up under the "keys" folder for the table in question - please there.

    2. If you need any furthur help on this issue, you will need to give us the DDL of the tables and the FK involved in this opreation, along with the INSER statement you are running and the Data that already exists in the Parent Table

    This is all the help we can give you, based on the limited information you have provided so far.


    Sanil Mhatre | Database Developer | MCTS | If you find my reply useful in any way, please vote it as helpful. If it has helped answer your question, please mark it as Answer. http://sqlwithsanil.com

    • Proposed as answer by Kalman Toth Sunday, December 2, 2012 2:22 PM
    • Marked as answer by Iric Wen Friday, December 7, 2012 8:34 AM
    Friday, November 30, 2012 6:31 PM

All replies

  • What table are you doing an insert to, and what is its DDL?

    What is the DDL for the table dbo.Person_M, name din the error message?


    "Premature optimization is the root of all evil." - Knuth

    If I provoked thought, please click the green arrow

    If I provoked Aha! please click Propose as Answer

    Friday, November 30, 2012 3:45 PM
  • You did not post DDL. You did not post code. How do you expect anyone to answer your questions? Why are you being so rude? 

    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Friday, November 30, 2012 5:49 PM
  • I see two issues ;

    1. The Foreign Key constraint DOES NOT show up under the Constraint Folder in SSMS Object explorer, it will show up under the "keys" folder for the table in question - please there.

    2. If you need any furthur help on this issue, you will need to give us the DDL of the tables and the FK involved in this opreation, along with the INSER statement you are running and the Data that already exists in the Parent Table

    This is all the help we can give you, based on the limited information you have provided so far.


    Sanil Mhatre | Database Developer | MCTS | If you find my reply useful in any way, please vote it as helpful. If it has helped answer your question, please mark it as Answer. http://sqlwithsanil.com

    • Proposed as answer by Kalman Toth Sunday, December 2, 2012 2:22 PM
    • Marked as answer by Iric Wen Friday, December 7, 2012 8:34 AM
    Friday, November 30, 2012 6:31 PM
  • Hi Tsql_New

    Here with providing some sample data for your understanding.

    Sunday, December 2, 2012 11:53 AM
  • Hi Ramesh,

    Use the INSERT CODE BLOCK icon (<>) to insert SQL code.

    Sample database:

    http://www.sqlusa.com/bestpractices2005/bankdatabase/


    Kalman Toth SQL 2008 GRAND SLAM
    New Book: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2012



    • Edited by Kalman Toth Sunday, December 2, 2012 3:05 PM
    Sunday, December 2, 2012 2:24 PM