title: SQL Server referential integrity add rows parent table
body: <p>I have a parent table </p>
  
  <pre><code>ptable (pid int, name varchar(10)); where pid is the primary key
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Child table ctable (pid int, cid int, cname varchar(10)); where pid references ptable.
  </code></pre>
  
  <p><code>ptable</code> has only 2 rows</p>
  
  <pre><code>pid   name
  1     Sales
  2     Marketing
  </code></pre>
  
  <p>Using C# application I am inserting rows into <code>ctable</code> from a text file. I want to be able to create a row in <code>ptable</code> if referential integrity is violated. Can this be done and how?</p>