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 Value from Stored procedure without output?

Author  Topic 

Mits
Starting Member

48 Posts

Posted - 2008-11-19 : 05:28:38
I would like to return a value from a stored procedure inside a stored procedure.
sp1 Calls sp2
sp2 has Select MyValue from MyTable -
I want to user MyValue in SP1

I could have easily achieved this using output parameter but my problem is i cannot change sp1 at all.

Is this possible to do this?

Mits

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-19 : 05:31:44
You can't change SP1 at all?

Have you tried using a LOOPBACK linked server and OPENRWOSET?
Have you tried

CREATE #Temp TABLE (i INT)

INSERT #Temp EXEC SP1

SELECT * FROM #Temp


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Mits
Starting Member

48 Posts

Posted - 2008-11-19 : 05:55:10
Thanks Peso for a quick reply and it works like magic!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-20 : 02:58:45
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 -