I have two tables which I want to combine. They each contain the same number of rows, and I want my result to have the same number of rows but the columns from both. It doesn't matter which row from table A is matched to which row from table B. The reason for this is that the query I'm writing will link the rows, so at the moment there is no link between them.
My current approach (SQL below) is to select the data from each table with a row number, then join the tables based on that row number. This gives the result I want, but is there an easier way to do it?
SELECT IdA, IdB
FROM (
SELECT IdA, ROW_NUMBER() OVER(ORDER BY IdA) RowNum
FROM TableA
) a
JOIN (
SELECT IdB, ROW_NUMBER() OVER(ORDER BY IdB) RowNum
FROM TableB
) b
ON a.RowNum = b.RowNum;