如何将存储过程返回的表存入表或表变量中?谢谢

YiYanXiYin 2004-07-01 04:20:35
--try this test
--如何将存储过程返回的表存入表或表变量中??
create proc test_get_result_table_from_proc
as
select 'abc',133
union
select 'cdef',134


go

exec test_get_result_table_from_proc

--在这里如何将test_get_result_table_from_proc返回的表存入表或表变量中??


drop proc test_get_result_table_from_proc
...全文
145 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
YiYanXiYin 2004-07-01
  • 打赏
  • 举报
回复
倒霉,我测试时恰恰就是使用的表变量
zjcxc 元老 2004-07-01
  • 打赏
  • 举报
回复
我上面用的是临时表,实际处理时,可以用临时表/正式表,不支持表变量
zjcxc 元老 2004-07-01
  • 打赏
  • 举报
回复
--try this test
--如何将存储过程返回的表存入表或表变量中??
create proc test_get_result_table_from_proc
as
select 'abc',133
union
select 'cdef',134
go

--创建保存数据的临时表
create table #t(a varchar(10),b int)

--调用存储过程
insert #t exec test_get_result_table_from_proc

--显示结果
select * from #t

--删除临时表
drop table #t
go

drop proc test_get_result_table_from_proc

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧