title: Save SQL query results to a table
body: <p>I want to save my adjusted query results into a table. For example I have codes 350.8, 351.94 and I have T-SQL code to remove the decimal points resulting in the adjusted results 350,351 etc. I want to save the results into a table, not Excel. Is this possible?  </p>
  
  <p>I see you can create a new table but with the same columns, not the new adjusted results. The below doesn't work as SQL Server doesn't recognise adjusted1, 2 and 3.</p>
  
  <pre><code>CREATE TABLE DiagAdj 
  (
       encounter_id NUMERIC,
       di_1 INT, 
       di_2 INT, 
       di_3 INT,
       adjusted1 INT,
       adjusted2 INT,
       adjusted3 INT,
  );
  
  INSERT INTO DiagAdj (encounter_id, adjusted1, adjusted2, adjusted3)
      SELECT encounter_id, adjusted1, adjusted2, adjusted3
      FROM dbo.Encounters
  </code></pre>
  
  <p>Decimal places removed. I want to save down adjusted3 results into a table</p>
  
  <pre><code>SELECT 
      encounter_id, di_3, -- now, try to cast to int the remainder, ending right before the decimal
      adjusted3 = TRY_CONVERT(int,LEFT(di_3, COALESCE(NULLIF(CHARINDEX('.', di_3) - 1, -1), 255)))
  FROM 
      dbo.Encounters;
  </code></pre>