//tableA:a1,a2
//tableB:a1,b2create table #tt(a1 varchar(15),a2 varchar(10),b2 varchar(20))
insert into #tt
select tableA.a1,a2,b2
from tableA a,TableB b
where a.a1=b.a1
insert into #tt
select a1,a2,''
from tableA where a1 not in (select a1 from tableB)insert into #tt
select a1,b2,''
from tableB where a1 not in (select a1 from tableA)select * from #tt  --table #tt is you need 
--you can use the virtual table or table eistsed
drop table #tt