日期:2014-05-17 浏览次数:20471 次
create table A表
(objCode char(6),Acc char(12),Amt decimal(8,2),remark varchar(20),atype int)
create table B表
(objCode char(6),Acc char(12),Amt decimal(8,2),remark varchar(20),atype int)
insert into A表
select 'B6BA','996000010003',600.00,'New DATA',0
insert into B表
select 'B6BA','996000010070',999.00,'O',1 union all
select 'B6BA','996000010070',-7290.00,'AAAA',1
select isnull(a.objCode,b.objCode) 'objCode',a.Acc,a.Amt,a.remark,
b.Acc,b.Amt,b.remark
from
(select row_number() over(order by getdate()) 'rn',*
from A表) a
full join
(select row_number() over(order by getdate()) 'rn',*
from B表) b on a.rn=b.rn
/*
objCode Acc Amt remark Acc Amt remark
------- ------------ ------------ -------------------- ------------ ------------- --------------------
B6BA 996000010003 600.00 New DATA 996000010070 999.00 O
B6BA NULL NULL NULL 996000010070 -7290.00 AAAA
(2 row(s) affected)
*/