我想这是你想要的。尝试一次,它可以帮助你
按照您的程序输出遵循以下查询
create table #tempp (col1 varchar(50),col2 bigint)
insert into #temp
exec p1
create table #tempp1 (col1 varchar(50),col2 bigint)
insert into #tempp1
exec p2
select t1.col1,t.col2,t1.col2 from #tempp t
full join #tempp1 t1 on t.col1=t1.col1
我已经创建的样本数据,就像你的程序输出数据和我的数据库试图
select * into #tempp from (
select 'p-1' as col1,52 col2
union all
select 'p-2',25
) as a
select * into #tempp1 from (
select 'p-1' as col1,20 col2
union all
select 'p-2',2
union all
select 'p-3',5
) as a
select t1.col1,t.col2,t1.col2 from #tempp t
full join #tempp1 t1 on t.col1=t1.col1
你的输出看起来像
+------+------+------+
| col1 | col2 | col2 |
+------+------+------+
| p-1 | 52 | 20 |
| p-2 | 25 | 2 |
| p-3 | NULL | 5 |
+------+------+------+
[将存储过程的结果插入临时表中的可能副本](http://stackoverflow.com/questions/653714/insert-results-of-a-stored-procedure-into-a-temporary-表) –
嗨我试过,但抛出错误。 – rahul