| Author |
Topic |
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2005-06-15 : 17:25:33
|
| I want to say:usp_get_age is a proc that returns the age, not as a variable via OUTPUT, but as a recordset,ie. exec usp_get_age will return in the query analyzer window, 21.I want to capture this value in a variable.Declare @x INTset @x = usp_get_age?? |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2005-06-15 : 17:53:43
|
| Not as pretty as I would imagine a dbaslut is but....maybe something like this Declare @x INTcreate table #abc(col1 int)insert into #abcexec usp_get_ageselect @x = col1 from #abcselect @xdrop table #abcDuane. |
 |
|
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2005-06-15 : 18:04:09
|
| hmm... so I'd have to use a table to capture the value, select that value and then drop the table? .... gotta be a better way... |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2005-06-15 : 18:06:44
|
| why not code a function that returns int - similar to the stored proc?Duane. |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-06-15 : 18:10:43
|
| What do you have against output param? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-06-15 : 18:15:36
|
| Yes you must use a temp table if you want to work with the results of a stored procedure. You can not use table variables, since you can't use exec when inserting into one. I'd go with Duane's suggestion about a function if you don't want to use a temp table. However, if you really are only returning one value from your stored procedure, then you should be using an OUTPUT parameter as Nathan is suggesting. That's what they are for.Tara |
 |
|
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2005-06-16 : 12:26:54
|
quote: Originally posted by nathans What do you have against output param?
nothing against it nathans, its just the current proc doesn't have age as an output parameter.. :( |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-06-16 : 12:39:31
|
| If you cannot alter the proc then, as Tara and Duane mentioned, you'll have to capture the resultset into a temp table and nab it there. |
 |
|
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2005-06-16 : 13:52:58
|
| hmm... temp table it is then.. thanks all.. |
 |
|
|
|