declare @a table(aa int,bb int,cc int)
insert into @a select 1,2,3 union all
select 2,2,4
declare @b table(aaa int)
insert into @b select 1 union all
select 3
select id1=identity(int,1,1),a.* into #a from @a a
select id2=identity(int,1,1),b.* into #b from @b b
select a.aa,a.bb,a.cc,b.aaa from #a a,#b b where a.id1=b.id2
drop table #a,#b
result:
aa bb cc aaa
----------- ----------- ----------- -----------
1 2 3 1
2 2 4 3
select id=identity(int,1,1),* into #t1 from t1 order by aa
select id=identity(int,1,1),* into #t2 from t2 order by aaa
select a.aa,a.bb,a.cc,b.aaa from #t1 a,#t2 b where a.id=b.id