Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 save the result set returned by a sp

Author  Topic 

rolandsantos
Starting Member

24 Posts

Posted - 2008-02-11 : 22:48:15
hi guys, just want to know how to do it. i have a stored proc that returns a result set from different tables,

ex.

exec my_proc

will return the ff:

description amount
aa 12
bb 15

my problem is that i want to insert the result of this proc to an existing table

i used the command insert into my_table from exec my_proc
but did not work, do you have any command that will work? thanks a lot

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-02-11 : 22:51:02
CREATE TABLE my_table (...)

INSERT INTO my_table
EXEC my_proc


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-11 : 23:11:25
It should work. If not what was error you got?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-12 : 01:52:39
Also refer http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -