title: Check if entry NOT EXISTS in SQL
body: <p>I am trying to insert data from one table that was imported from an Excel file into another table with the same exact columns. When I go to insert all the data </p>
  
  <pre><code>    INSERT INTO [NQL_RawData].[dbo].[WM_MFGPNs]
      ([Manufacturer],[MPNWP],[MFGPN],[Cage],[Url],[DataSheetUrl],[Description],[Status],[NRND],[RoHS],[PbFree],[LOT],[LeadTime],[AddedOn],[AddedBy])
  
      SELECT [Manufacturer],dbo.BuildPNWP([MFGPN],0),[MFGPN],[Cage],[Url],[DataSheetUrl],[Description],[Status],[NRND],[RoHS],[PbFree],[LOT],[LeadTime],[AddedOn],[AddedBy]
  
      FROM [NQL_RawData].[dbo].[wm_BulkImport] WHERE Manufacturer = 'MFG NAME'        
  </code></pre>
  
  <p>it comes up with this error message </p>
  
  <p>Msg 2627, Level 14, State 1, Line 1
  Violation of PRIMARY KEY constraint 'PK_MFGPNs_1'. Cannot insert duplicate key in object 'dbo.WM_MFGPNs'.
  The statement has been terminated.</p>
  
  <p>So I changed the query to include WHERE NOT EXISTS </p>
  
  <pre><code>    INSERT INTO [NQL_RawData].[dbo].[WM_MFGPNs]
      ([Manufacturer],[MPNWP],[MFGPN],[Cage],[Url],[DataSheetUrl],[Description],[Status],[NRND],[RoHS],[PbFree],[LOT],[LeadTime],[AddedOn],[AddedBy])
  
      SELECT [Manufacturer],dbo.BuildPNWP([MFGPN],0),[MFGPN],[Cage],[Url],[DataSheetUrl],[Description],[Status],[NRND],[RoHS],[PbFree],[LOT],[LeadTime],[AddedOn],[AddedBy]
  
      FROM [NQL_RawData].[dbo].[wm_BulkImport] 
  
      WHERE NOT EXISTS( 
      SELECT [MFGPN] 
      FROM [NQL_RawData].[dbo].[WM_MFGPNs]
      WHERE Manufacturer = 'MFG NAME'     
      )
  </code></pre>
  
  <p>But I still receive the same error message. Any ideas?</p>