Solved

insert into using exec proc

Posted on 2003-12-05
4
1,860 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cannot create ODBC connection over the network 3 1,191
Sybase sample database 13 663
SyBase SQL Query 7 143
sql statement error 18 72
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now