title: Recursive Update Statement
body: <p>I need to create a recursive update statement that updates from another table so for ex..</p>
  
  <pre><code>    Table1
      (
         IdNumberGeneratedFromAService INT NOT NULL,
         CodeName NVARCHAR(MAX)
      )
  
      Table2 
      (
         Table2Id Auto_Increment,
         Name NVARCHAR(MAX),
         IdNumberThatComesFromTabl1,
         CodeNameForTable1ToMatch
      )
  </code></pre>
  
  <p>the issue is CodeNameForTable1ToMatch is not unique so if Table1 has 2 idnumber for the same code and there are two rows in Table2 with the same CodeName I want to update the rows in table2 in sequence so first row gets the first idnumber and second row gets the second id number.</p>
  
  <p>Also want to do it without cursor....</p>
  
  <pre><code>SAMPLE DATA
  
  Table1
  idNumber            Code
  C145-6678-90        Code1
  C145-6678-91        Code1
  C145-6678-92        Code1
  C145-6678-93        Code1   
  C145-6678-94        Code1
  
  
  Table 2
  AutoIncrementIdNumber       Code        IdNumber
  1               Code1       {NULL}
  2               Code1       {NULL}
  3               Code1       {NULL}
  4               Code1       {NULL}
  5               Code1       {NULL}
  
  
  C145-6678-90 needs to got 1
  C145-6678-91 needs to got 2
  C145-6678-92 needs to got 3
  C145-6678-93 needs to got 4
  C145-6678-94 needs to got 5
  
  in one update statement
  </code></pre>