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 2000 Forums
 SQL Server Development (2000)
 Select from a stored proc

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2007-05-29 : 17:21:48
Hello, All,

How to feed a returned recordset from a stored proc into a t-sql select statement?

I have seen example of getting a single integer value, or using an output param in the sp to return data.

In my case, I cannot change to sp to make it use output param.

So, normally here is how it returns
exec mySP @inputID
and my t-sql normally look like this
SELECT * into #mytmpTable from mytable where ID = @inputID

Now I want to switch the above FROM to from my stored proc, and the following two ways failed.
Exce #mytmpTable = mySP @inputID
or
Select * into #mytmpTable
Exec mySP @inputID
(Must specify table to select from)

Thanks!

By the way, I am using sql2000.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-05-29 : 17:30:35
You must first create the temp table, then put the results into it using insert into ... exec ...

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2007-05-29 : 17:51:29
Great, thanks!
Go to Top of Page
   

- Advertisement -