是否可以在存储过程中调用存储过程并将结果放入#temp 表中,而无需先创建临时表?
我试图从另一个存储过程中调用一个存储过程,并将结果放入临时表中,而不先创建临时表。是否可以这样做,或者有更好的方法吗?我想使用结果集具有多列和多行的 sprocB 或 functionB。谢谢。
sproc A
..
begin
-- create table #tmp.... -- Try not to create the #tmp table first if possible
exec sproc_B ... put results from sproc_B in #tmp
end
sproc B
..
@id int
..
begin
select table from aTable where id = @id
end
此处提出了类似的问题。
I'm trying to call a sproc from within another sproc and putting the results in a temp table without first creating the temp table. Is it possible to do this, or is there a better way? I want to use the sprocB or functionB whose result set has multiple columns and multiple rows. thx.
sproc A
..
begin
-- create table #tmp.... -- Try not to create the #tmp table first if possible
exec sproc_B ... put results from sproc_B in #tmp
end
sproc B
..
@id int
..
begin
select table from aTable where id = @id
end
Similiar question was asked here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,但是您必须在使用 in 之前创建表。语法是:
INSERT INTO YourTable EXEC YourProc
不用说,表的结构应该与 SP 的输出匹配?
Yes, but you have to create table prior to using in. The syntax is:
INSERT INTO YourTable EXEC YourProc
No need to say, that structure of the table should match the SP's output?