title: Checking for duplicates in 2 columns before insert involving NULL, SQL Server
body: <p>Currently I have a table1 with PrimaryKey, column1 and column2.
  My goal is, before inserting the data into the table to check if column1 + column2 is unique.</p>
  <p>Example:
  Current data in the table</p>
  <pre><code>**Primary key           column1           column2**
       1                    1               banana
       2                   NULL              NULL
       3                    2                NULL
       4                    1                NULL
  </code></pre>
  <p>Should successfully insert the below data:</p>
  <pre><code>**Primary key           column1           column2**
         5                   1               apple
         6                   3               banana
         7                   4                NULL
  </code></pre>
  <p>Should fail to insert the below data:</p>
  <pre><code>**Primary key           column1           column2**
         8                   1               banana
         9                   2                NULL
  </code></pre>
  <p>I would make the 2 fileds unique but I cant because of the NULL values which I cant fill with data right now.<a href="https://i.stack.imgur.com/VnnPr.png" rel="nofollow noreferrer">enter image description here</a></p>