|
-
Jul 29th, 2008, 10:48 AM
#1
Thread Starter
Hyperactive Member
Stored procedure result to variable
How would I assign the value of the result of executing a stored procedure to a variable.
I tried this:
But this assigns the return value and not the result , to @var.
I believe the return value will return 0 if no errors occur.
Thanks
-
Jul 29th, 2008, 10:51 AM
#2
Fanatic Member
Re: Stored procedure result to variable
I have not tried it but maybe you could do
Code:
set @var = exec proc1
CLanguage; 
IF Post = HelpFull Then
RateMe
Else
Say("Shut UP")
End If
DotNet rocks
VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?
-
Jul 29th, 2008, 11:18 AM
#3
Thread Starter
Hyperactive Member
Re: Stored procedure result to variable
No it didnt work,..
I tried this in the end it did work, I know I could also use output parameters.
Code:
DROP TABLE #temp_table
CREATE TABLE #temp_table (availability int)
INSERT INTO #temp_table exec SelectALLTest
SELECT availability FROM #temp_table
-
Jul 29th, 2008, 11:18 AM
#4
Thread Starter
Hyperactive Member
Re: Stored procedure result to variable
Got the feeling there must be a better way,.... without using OUTPUT parameters,..
-
Jul 29th, 2008, 11:44 AM
#5
Re: Stored procedure result to variable
It would depend on the stored procedure.
What are it's results? A single value, a resultset?
If the result is a single integer value just set the Return value of the sproc. It will then be loaded into your @var variable.
What have you got against OUTPUT parameters.
-
Jul 30th, 2008, 01:51 PM
#6
Thread Starter
Hyperactive Member
Re: Stored procedure result to variable
Hi, it´s a resultset.
I do not have anything against output parameters,but wouldn´t like to modify an existing sp.
-
Jul 30th, 2008, 02:10 PM
#7
Re: Stored procedure result to variable
if it's result set than Inline Table-Values function will be the best option for you, by this way you can directly worked upon the result set retun by function without creating Temp Table.
__________________
Rate the posts that helped you 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|