title: The select list for the INSERT statement contains fewer items than the insert list
body: <p>I'm trying to insert into a table variable, both from a View and from a Table, this is the code I'm attempting to use:</p>
  
  <pre><code>DECLARE @ResultCodes TABLE(ID_Audit INT,
                             AcctCode VARCHAR(3),
                             BidYear VARCHAR(4),
                             Num_Htls INT,
                             AuditStatus VARCHAR(50),
                             Account VARCHAR(3),
                             X INT, E INT, H INT, H_NLRA INT, N INT, Extra INT)
  
  INSERT INTO @ResultCodes(ID_Audit, AcctCode, BidYear, Num_Htls, AuditStatus, Account, 
                           X, E, H, H_NLRA, N, Extra)
      SELECT 
          ID_Audit,
          AcctCode,
          BidYear,
          COUNT(ID_RFP),
          Audit_Status,
          Account 
      FROM 
          dbo.c_Audit_Rec_Status 
      WHERE 
          ID_Status_Audit = 105
      GROUP BY ID_Audit,AcctCode,BidYear,Audit_Status,Account
          UNION
      SELECT 
          SUM(CASE WHEN ResultCode3 = 'X' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'E' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'H' AND Rate_Basis = 'LRA' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'H' AND Rate_Basis = 'NLRA' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'N' THEN 1 ELSE 0 END),
          0
      FROM 
          tbl_FA_Results WHERE AuditDate3 IS NOT NULL         
  
          SELECT * FROM @ResultCodes  
  </code></pre>
  
  <p>But I keep getting this error</p>
  
  <blockquote>
    <p>The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.</p>
  </blockquote>
  
  <p>I've looked at this a hundred times if I've looked at it once and it seems like it should be working, can anyone see what I'm missing?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is the code I ended up with that works like a charm. Sometimes a second set of eyes is all it takes:</p>
  
  <pre><code>DECLARE @ResultCodes TABLE(ID_Audit INT,AcctCode VARCHAR(3),BidYear VARCHAR(4),Num_Htls INT,AuditStatus VARCHAR(50),Account VARCHAR(3),X INT,E INT,H INT,H_NLRA INT,N INT,Extra INT)
  INSERT INTO @ResultCodes(ID_Audit,AcctCode,BidYear,Num_Htls,AuditStatus,Account,X,E,H,H_NLRA,N,Extra)
      SELECT 
          ID_Audit,
          AcctCode,
          BidYear,
          COUNT(c_Audit_Rec_Status.ID_RFP),
          Audit_Status,
          Account ,
          SUM(CASE WHEN ResultCode3 = 'X' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'E' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'H' AND Rate_Basis = 'LRA' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'H' AND Rate_Basis = 'NLRA' THEN 1 ELSE 0 END),
          SUM(CASE WHEN ResultCode3 = 'N' THEN 1 ELSE 0 END),
          0
      FROM 
          dbo.c_Audit_Rec_Status,
          tbl_FA_Results  
      WHERE 
          c_Audit_Rec_Status.ID_Status_Audit = 105 AND AuditDate3 IS NOT NULL
      GROUP BY ID_Audit,AcctCode,BidYear,Audit_Status,Account
  </code></pre>