title: How to do an inner join on row number in sql server
body: <p>SQL Server 2008</p>
  
  <p>Two tables:</p>
  
  <p>Table A has following data:</p>
  
  <pre><code>RowA
  RowB
  RowC
  RowD
  </code></pre>
  
  <p>Table B has following data:</p>
  
  <pre><code>Row4
  Row3
  Row2
  Row1
  </code></pre>
  
  <p>I want to get the following output:</p>
  
  <pre><code>RowA Row1
  RowB Row2
  RowC Row3
  RowD Row4
  </code></pre>
  
  <p>The only common value between the two tables is the row number</p>
  
  <p>I can get the data individually of course:</p>
  
  <pre><code>SELECT val
  FROM A
  ORDER BY val
  
  SELECT val
  FROM B
  ORDER BY val
  </code></pre>
  
  <p>But how do I join on the row number?</p>
  
  <p>And what if I don't have an order-by, but just want the rows in the order they come out?</p>
  
  <pre><code>RowA Row4
  RowB Row3
  RowC Row2
  RowD Row1
  </code></pre>
  
  <p>as in the join of</p>
  
  <pre><code>SELECT val
  FROM A
  
  SELECT val
  FROM B
  </code></pre>