[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

insert into using exec proc

Posted on 2003-12-05
4
Medium Priority
?
1,953 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 1500 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Ransomware, the malware that locks down its victim’s files until they pay up, has always been a frustrating issue to deal with. However, a recent mobile ransomware will make the issue a little more personal… by sharing the victim’s mobile browsing h…
WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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