title: Insert rows from TableA that are not in TableB using concatenated keys
body: <p>I have 2 tables.  TableA gets populated by a csv import and typically contains between 10k and 15k rows.  TableB has the same structure, and has now grown to about 95k rows.  In order to determine rows in TableA that are not in TableB, I need to compare a concatenation of 4 fields in TableA with the same concatenation in TableB.</p>
  <p>The code below has been working as TableB has been growing, but is just taking so long that it needs to be cancelled and does not finish.</p>
  <p>I strongly believe that the use of concatenated fields as a comparison is causing execution times to grow beyond usability.</p>
  <p>Is there a better approach to the problem?</p>
  <pre><code>DELETE FROM billing..whse_Temp
  BULK INSERT billing..whse_Temp
  FROM '/mnt/ABC/ABC.csv'
  WITH
  (
    FORMAT='csv',
    FIRSTROW=2,
    FIELDTERMINATOR=',',
    ROWTERMINATOR='\r\n'
  )
  
  INSERT INTO billing..whse
  SELECT * FROM billing..whse_Temp S
  WHERE CONCAT(S.RunTimeStamp, S.CS_Datacenter,S.Customer, S.ServerName) NOT IN
    (
      SELECT CONCAT(RunTimeStamp, CS_Datacenter, Customer, ServerName) 
      FROM billing..whse
    )
  </code></pre>