0

I need to INSERT INTO a new table (FinalTable) from 2 unrelated tables, but values from Table1 will need to be repeat for every value pulled from Table2.

Example:

Table1                      Table2                      
AK                          ID1
AL                          ID2
AR                          ID3
AZ                          ID4
...                         ...

FinalTable
Column1       Column2
ID1           AK
ID1           AL
ID1           AR
ID1           AZ
ID2           AK
ID2           AL
ID2           AR
ID2           AZ
...

Is it possible to do this without being able to JOIN the two SELECTed tables?

2

This is called a cross join.

INSERT dbo.FinalTable(Column1, Column2)
SELECT t1.col, t2.col 
  FROM dbo.Table1 AS t1
  CROSS JOIN dbo.Table2 AS t2;
| improve this answer | |
  • Thank you Aaron, that took care of it! – eXult May 7 '19 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.