Skip to content
Advertisement

sql to combine two unrelated tables into one

I have tables

table1

and table2

I want to combine the two tables, which have no common field into one table looking like:

table 3

ie, it is like putting the two tables side by side.

I’m stuck! Please help!

Advertisement

Answer

Get a row number for each row in each table, then do a full join using those row numbers:

This is assuming SQL Server >= 2005.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement