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
 Transact-SQL (2000)
 Return table variable from one sp to another

Author  Topic 

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2006-04-28 : 17:03:15
Hi,

I have a sp which returns a table variable.

How do I access this variable from another sp which calls the sp which returns the table?

Cheers, XF.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-04-28 : 17:37:40
>>I have a sp which returns a table variable.
Do you mean it SELECTs out of a table variable?

There are only a few ways to get data from an SP: SELECT, RETURN [int], OUTPUT parameters and Raiserror.

Table variables can not be used as parameters. Also you can't EXEC into a table variable.

One thing you could do is create a temp table (#<tableName>) in your calling procedure and insert into it the results of your called procedure.

ie:

create table #temp1 (<colList with same structure as called sp result set>)
insert #temp (<colList>)
exec MyOtherSP

Be One with the Optimizer
TG
Go to Top of Page

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2006-04-28 : 18:00:44
Yes, it SELECT's from a table variable in the last line of code.
Go to Top of Page
   

- Advertisement -