title: Quicker way to update all rows in a SQL Server table
body: <p>Is there a more efficient way to write this code? Or with less code?</p>
  
  <pre><code>SELECT * 
  INTO #Temp 
  FROM testtemplate
  
  Declare @id INT
  Declare @name VARCHAR(127)
  
  WHILE (SELECT Count(*) FROM #Temp) &gt; 0 
  BEGIN 
  
      SELECT TOP 1 @id = testtemplateid FROM #Temp
      SELECT TOP 1 @name = name FROM #Temp
  
      UPDATE testtemplate
      SET testtemplate.vendortestcode = (SELECT test_code FROM test_code_lookup WHERE test_name = @name)
      WHERE testtemplateid = @id
  
       --finish processing 
      DELETE #Temp Where testtemplateid = @id
  END
  DROP TABLE #Temp
  </code></pre>