Solved

insert into using exec proc

Posted on 2003-12-05
4
1,930 Views
Last Modified: 2008-02-01
Hi,

Is it possible to insert into a temp table, the results from exec'ing a stored proc?

i.e.

insert into #temp1(col1, col2, col3...)
 exec myProc

Cheers, Andy
0
Comment
Question by:amtate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:ChrisKing
ID: 9886670
That is a MS-SQL extention that is not (yet) supported in Sybase.
However I too would have some uses for it whenit comes.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9893081
Chris is right. However, you can insert the final result into a temp table before exiting the proc and access the same temp table within the parent proc.

Example:

Create procedure sp_test
As
Begin
-- Final Step before exiting
insert into #temptable (col1, col2)
select col1, col2
from MyTable
End

--Parent Proc
Create Proc sp_Parent
As
Begin

exec sp_test

select * from #temptable

End


HTH

Namasi Navaretnam.
0
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 500 total points
ID: 9894488
One more point I should add, to make sp_Parent compile you will need to create #temptable outside the procedure.

create table #temptable
(
col1 int,
col2 varchar(100),
coletc int
)

go
--Parent Proc
Create Proc sp_Parent
As
Begin

exec sp_test

select * from #temptable

End

go
Drop table #temptable
go

HTH

Namasi Navaretnam

0
 

Author Comment

by:amtate
ID: 9895371
Thanks Namasi - this was helpful...

Rgds, Andy
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let’s face it: one of the reasons your organization chose a SaaS solution (whether Microsoft Dynamics 365, Netsuite or SAP) is that it is subscription-based. The upkeep is done. Or so you think.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question