title: SQL Server : insert record if not duplicate over certain columns
body: <p>I have very limited experience with SQL, so I am struggling to ask the right question. </p>
  
  <p>Imagine I have a table with 5 columns</p>
  
  <pre><code>Simulation_ID   Param_1   Param_2   Param_3   Param_4  Param_5  Output_folder
  </code></pre>
  
  <p>This table summarizes simulations that are run using certain parameters, and the output folder of the result.</p>
  
  <p>I would like to prevent duplicates from being inserted in this table. In my case, a simulation must have a unique set of parameters. Therefore, no simulation should have the same combination of parameters. I was tempted to define a primary key as <code>(ID, Param_1, Param_2, Param_3, Param_4, Param_5)</code>, but I read that composite keys are not recommended due to poor performance. Currently, <code>Simulation_ID</code> is the primary key of the table.</p>
  
  <p>Imagine if someone wants to add a simulation that has a unique ID, but the same set of parameters that was used by another existing record. </p>
  
  <p>Example:</p>
  
  <p>Current data in the table:</p>
  
  <pre><code>Simulation_ID   Param_1   Param_2   Param_3   Param_4  Param_5  Output_folder
  -----------------------------------------------------------------------------
  1               0.5       0.4       0.3       0.2      0.1      folder1
  2               10        0.4       0.3       0.2      0.1      folder2
  </code></pre>
  
  <p>And the new record is:</p>
  
  <pre><code>Simulation_ID   Param_1   Param_2   Param_3   Param_4  Param_5  Output_folder
  -----------------------------------------------------------------------------
  3               0.5       0.4       0.3       0.2      0.1      folder3
  </code></pre>
  
  <p>Technically, this record, although having a different ID and <code>output_folder</code>, has the exact same values (<code>Param_1</code> to <code>Param_5</code>) as record #1. I would like to do a check where if this happens, an error is thrown and the record isn't inserted.</p>
  
  <p>Is that possible? In reality, my table has over 20 columns, and 17 out of 20 columns is what I would like to use to flag and prevent duplicates.</p>