Solved

insert into using exec proc

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2010 with SyBase 3 842
SyBase SQL Syntax 7 316
Sybase sample database 13 692
Sybase IQ how to log personalized Users? 1 203
Troubleshooting common task sequence error codes
Read about the ways of improving workplace communication.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

18 Experts available now in Live!

Get 1:1 Help Now