title: SQL while loop with Temp Table
body: <p>I need to create a temporary table and then update the original table. Creating the temporary table is not a problem. </p>
  
  <pre><code>create table #mod_contact
  ( 
      id INT IDENTITY NOT NULL PRIMARY KEY,
      SiteID INT,
      Contact1 varchar(25)
  )
  
  INSERT INTO #mod_contact (SiteID, Contact1)
  select r.id, r.Contact  from dbo.table1 r where CID = 142
  GO
  </code></pre>
  
  <p>Now I need to loop through the table and update r.contact = SiteID + r.contact</p>
  
  <p>I have never used a while loop before and can't seem to make any examples I have seen work. </p>