SQLTeam.com | Weblogs | Forums

Creating new table from two table

Table 1
COL-A COL-B COL-C COL-D
1 2 2 A
1 2 4 B
2 1 3 C
Table 2
ID
1011123
1011124
1011125
.
.
.
Want to Produce table
ID COL-A COL-B COL-C COL-D
1011123 1 2 2 A
1011123 1 2 4 B
1011123 2 1 3 C
1011124 1 2 2 A
1011124 1 2 4 B
1011124 2 1 3 C
1011125 1 2 2 A
1011125 1 2 4 B
1011125 2 1 3 C

Thanks in advance.

What have you tried? Seems a simple Cross Apply will do

please provide your data using proper DDL and DML for ex

create table1

insert into table1

I'm not sure why you'd want to do this but this is a simple "Cartesian Product" that you can do just by doing a CROSS JOIN on the two tables.

 SELECT  t2.*
        ,t1.*
   FROM      dbo.Table1 t1
  CROSS JOIN dbo.Table2 t2
;

Thanks a lot. I forgot about it.

Regards,