title: Add a IF ...ELSE statement to stored procedure to skip duplicate primary keys
body: <p>I have a try catch in my physical C# code that just skips this insert process when a error accrues and continues the loop to fill the database. However this is bad coding practice.</p>
  
  <p>So I would like to add an <code>IF</code> statement to the stored procedure below that will just skip if a primary key is already there. My primary key is <code>@id</code>. </p>
  
  <p>How can I go about this?</p>
  
  <pre><code>CREATE PROCEDURE InsertProc
      (
      @id int, 
      @to nvarchar(100), 
      @from nvarchar(100), 
      @subject nvarchar(100), 
      @date datetime
      )
  AS
      INSERT INTO Emails_Log (Email_ID, e_To, e_From, e_Subject, e_Date) 
      VALUES (@id, @to, @from, @subject, @date)
  </code></pre>