select * from (select row_number() over(order by getdate()) no,aa from tb) a full join (select row_number() over(order by getdate()) no,bb from tb) b on a.no=b.no full join (select row_number() over(order by getdate()) no,aa from tb) c on a.no=c.no
select aa,id=indentity(1,1) into tb1 from tb where aa<>'' select bb,id=indentity(1,1) into tb2 from tb where bb<>'' select cc,id=indentity(1,1) into tb3 from tb where cc<>'' select aa,bb,cc from tb1 a full outer join tb2 b on a.id=b.id full outer join tb3 c 2 on b.id=c.id drop table tb1,tb2,tb3
select identity(int,1,1) as id , aa into #tb1 from t2 where aa<>'' select identity(int,1,1) as id , bb into #tb2 from t2 where bb<>'' select identity(int,1,1) as id , cc into #tb3 from t2 where cc<>''select * from #tb1 a full join #tb2 b on a.id =b.id full join #tb3 on a.id= c.id
(select row_number() over(order by getdate()) no,aa from tb) a
full join
(select row_number() over(order by getdate()) no,bb from tb) b on a.no=b.no
full join
(select row_number() over(order by getdate()) no,aa from tb) c on a.no=c.no
select aa,id=indentity(1,1) into tb1 from tb where aa<>''
select bb,id=indentity(1,1) into tb2 from tb where bb<>''
select cc,id=indentity(1,1) into tb3 from tb where cc<>''
select aa,bb,cc
from tb1 a
full outer join tb2 b
on a.id=b.id
full outer join tb3 c 2
on b.id=c.id
drop table tb1,tb2,tb3
select identity(int,1,1) as id , bb into #tb2 from t2 where bb<>''
select identity(int,1,1) as id , cc into #tb3 from t2 where cc<>''select * from #tb1 a full join #tb2 b on a.id =b.id full join #tb3 on a.id= c.id