Groups | Blog | Home
all groups > sql server (alternate) > january 2004 >

sql server (alternate) : Storing a stored-proc's result into a temp table



takayasu.harada NO[at]SPAM csfb.com
1/29/2004 11:40:54 AM
I'm trying to write a SQL that stores a result from a stored-procedure
into a temporary table.

mountain man
1/29/2004 10:43:26 PM
[quoted text, click to view]


1) Create table test (
col001 varchar(10) null
)
go

2) insert into test
select substring(description,1,10)
from someothertable

Erland Sommarskog
1/29/2004 11:33:17 PM
thirdman (takayasu.harada@csfb.com) writes:
[quoted text, click to view]

Yes, you can say

INSERT #tmp (...)
EXEC your_sp

Beware that you cannot nest this constructs.

I don't know what you want to do, but this article mught include information
that is useful for you: http://www.sommarskog.se/share_data.html.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Simon Hayes
1/30/2004 12:30:35 AM

[quoted text, click to view]

Create a temp table with the same structure as the result set of the stored
procedure, then do this:

insert into #table
exec dbo.MyProc

But there are other options available also - in SQL 2000, a table-valued UDF
is often useful. See here for more information:

http://www.sommarskog.se/share_data.html

Simon

AddThis Social Bookmark Button